Automate Cloud Run deployment in a minute

  1. Run Go locally
  2. Run Go on Google Cloud Run
  1. Running Go locally -:
+-- Dockerfile
+-- docker-compose.yml
+-- app
| +-- app.go
FROM golang:1.10COPY ./app /go/src/github.com/user/sites/app
WORKDIR /go/src/github.com/user/sites/app
RUN go get -u github.com/gin-gonic/gin && go get ./RUN go buildCMD go get github.com/pilu/fresh && \
fresh; \
EXPOSE 8080
version: '2'
services:
golang.go:
container_name: golang.go
build: ./
environment:
- VIRTUAL_HOST=custom.pv
- APP_ENV=dev
volumes:
- ./app:/go/src/github.com/user/sites/app
ports:
- "5000:8080"
package mainimport (
"github.com/gin-gonic/gin"
"fmt"
)
func regRoutes(routes *gin.Engine) { routes.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"status": "up",
})
})}func main() { routes := gin.Default()
regRoutes(routes)
routes.Run() // run in 8080 port
}
components install beta --quiet gcloud auth configure-docker
docker build -t golangcloudrun:latest .docker tag  golangcloudrun:latest gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/golangcloudrun docker push gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/golangcloudrun:latest 
** components install beta --quiet **** gcloud beta run deploy ${CLOUD_RUN_SERVICE_NAME} — image gcr.io/${{ GCLOUD_PROJECT_ID }}/golangcloudrun — platform managed — region us-central1 — project=${{ secrets.GCLOUD_PROJECT_ID }} **

--

--

--

Software Development Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Passing a Parameter through an ICommand in Xamarin

NIST Digital Library of Mathematical Functions

GCP Cloud Run — Serverless Stateless Containers

Mocked backend in iOS applications

Pimsleur Vs Mondly — Best Review Of #1 Language Apps

E-fleet System

Busuu vs LinguaLift: Effectivity Of These 2 Apps

Scrapy: Background

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ujwal dhakal

ujwal dhakal

Software Development Enthusiast

More from Medium

Multi-Cloud SetUp: — RDS on AWS & GKE on GCP

Choosing Between GKE and Cloud Run

Cloud Run vs. GKE decision tree

-Datadog | Cloud Monitoring

Way to Lower Cloud SQL InstanceCost