Skip to content

Latest commit

 

History

History

helloworld

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Cloud Run Hello World Sample

This sample shows how to deploy a Hello World application to Cloud Run.

Run in Google Cloud

Setup

  1. Set up for Cloud Run development

  2. Clone this repository:

    git clone https://github.com/GoogleCloudPlatform/ruby-docs-samples.git
  3. Create an Artifact Registry:

    gcloud artifacts repositories create containers --repository-format docker --location ${GOOGLE_CLOUD_REGION}

Build

docker build --tag helloworld:ruby .

Run Locally

docker run --rm -p 9090:8080 -e PORT=8080 helloworld:ruby

Test

# Set an environment variable with your GCP Project ID
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>

# Install dependencies
bundle install

# Run tests
bundle exec rspec

Deploy

# Set an environment variable with your GCP Project ID
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>

# Set an environment variable with your Google Cloud region
export GOOGLE_CLOUD_REGION=<REGION>

# Submit a build using Google Cloud Build
gcloud builds submit --tag ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/helloworld

# Deploy to Cloud Run
gcloud run deploy helloworld --image ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/helloworld

Visit your deployed container by opening the service URL in a web browser.