'How to deploy an Go application on GCP (Cloud run)?
Created a simple Golang Application which has a server created via Gin web framework, which accepts a requests and provides responses for it. now to deploy it built a docker container and then host that on google cloud platform services that is cloud run.
Solution 1:[1]
Requirements -> Google Cloud SDK, Docker
Step 1 -> Create a docker file for the application so that you can create an image from it and add to Container registry on GCP, from where one can use that container to deploy the application on cloud run. dockerfile example
Step 2 -> Build and run the container on local device to check for issues. build and run on local device
Step 3 -> Login to google cloud from terminal using command
gcloud auth login
and also authorise docker-configure using command
gcloud auth configure-docker
Step 4 -> Tag the image
docker tag goapp gcr.io/project-name-from-GCP/go-app
Step 5 -> push your image onto container registry using commands
docker push gcr.io/project-name-from-GCP/go-app
pushed image to Google container registry
- Step 6-> Use the above tagged image on google cloud run to create a service and deploy the application.
extra - if device is Mac M1 , then Executables in the container image must be compiled for Linux 64-bit. Cloud Run specifically supports the Linux x86_64 ABI format , hence use --platform linux/amd64 in docker build to prevent issues while deployment on cloud run
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
