Deploy a Docker image to Google Cloud using Cloud Run

Search for a command to run...

No comments yet. Be the first to comment.
SonarQube is a great code inspection tool for code quality and code security. It provides Docker image for easy setup of the server, and Maven plugin for code inspection. Install and Setup SonarQube Install SonarQube from Docker image. docker run ...
In this article, we'll write a JUnit Test configured with Environment Variables using junit-pioneer library. First of all, we need to add the junit-pioneer library and maven-surefire-plugin to the Maven pom.xml. <project> <properties> <p...
Problem The problem occurs when using the Python requests library, the chardet library is not installed. /Users/adacheng/Library/Python/3.9/lib/python/site-packages/requests/__init__.py:86: RequestsDependencyWarning: Unable to find acceptable charact...

Apache Kafka is an open-source distributed event streaming platform for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. Introduction This article aims to provide basic hands-on instructions ...

Problem When AWS STS module is included in a Spring Boot Application, exception complaining region not set is thrown. Maven pom.xml <dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>sts</artifactId> </dependency> Error M...

Installation Follow the instruction in this article to install Trivy. Scan To scan the docker image: Build the image. docker build . -t hello-world Scan the image. trivy scan hello-world

In this article, I would like to document how I deploy a Docker image to Google Cloud using Cloud Run.
Refer to my article Dockerizing a Node.js web application for developing a Node.js application and building a docker image.
If you have already created a project, you can skip this section and go directly to Configure a Google Cloud Project.
In Google Cloud Shell, perform the following steps:
Lists credentialed accounts and make sure the desired account is set active.
gcloud auth list
Create a project.
gcloud projects create PROJECT_ID
Enable Billing in Google Cloud Console.
List all projects.
gcloud projects list
Set the default project.
gcloud config set project PROJECT_ID
Print the project ID.
echo $GOOGLE_CLOUD_PROJECT
Set the default zone if it is not set:
gcloud config set compute/zone COMPUTE_ZONE
Set the default region if it is not set:
gcloud config set compute/region COMPUTE_REGION
Show the configuration.
gcloud config list
Enable APIs in Google Cloud Shell.
Enable Cloud Run.
run.googleapis.com
Submit the docker image to Container Registry.
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/website
List all container images in this project to verify that the docker image has been submitted successfully.
gcloud container images list
Deploy the Container Image to Cloud Run.
gcloud run deploy CONTAINER_NAME \
--image gcr.io/$GOOGLE_CLOUD_PROJECT/DOCKER_IMAGE_NAME:DOCKER_IMAGE_VERSION \
--platform managed \
--region GCR_REGION \
--allow-unauthenticated
Replace CONTAINER_NAME with the desired Container Name.
Replace DOCKER_IMAGE_NAME with your docker image name.
Replace DOCKER_IMAGE_VERSION with the version of your docker image name.
Replace PROJECT_ID with your project ID.
Replace GCR_REGION with your region, such as europe-west2.
Here below is a working example:
gcloud run deploy portfolio-website \
--image gcr.io/$GOOGLE_CLOUD_PROJECT/website:latest \
--platform managed \
--region europe-west1 \
--allow-unauthenticated
Check that the web application is running by opening URL of the Cloud Run Service in a web browser.

