Deploying Go Apps to Google Cloud Run

https://lobste.rs/rss Hits: 6
Summary

A few of my projects use the same Makefile and Dockerfile to handle deployment to Google Cloud Run. Rather than reinvent the wheel every time, I packaged it up as a reusable template on GitHub: cloud-run-go-deployment. Drop it into a project, hand it to your AI of choice to adjust for your needs, and you’re most of the way there. Why Cloud Run Google Cloud Run is one of those tools that does exactly what it says with very little ceremony. You give it a Docker image, it runs it. You don’t manage servers, you don’t configure scaling rules, you don’t worry about uptime. It scales to zero when there’s no traffic which is great if you’re running side projects and it scales up automatically when requests come in. Because billing is per 100ms of actual execution, a low-traffic app can run for well under a dollar a month. Compared to something like AWS, where deploying a containerized app typically involves Lambda with CloudFront or a load balancer in front, Cloud Run is refreshingly simple. You deploy a Docker image, map a custom domain, and get a free SSL certificate. That’s it. I wrote more about that tradeoff in my earlier article on Polar Bear Blog, a lightweight Go blogging system I built specifically because Cloud Run made self-hosting feel tractable. Getting Started The template uses a .env file for configuration. Copy these four values in and you’re ready to go: GCP_PROJECT_ID=your-gcp-project-id GCP_REGION=us-central1 GCP_IMAGE_NAME=helloworld GCP_CLOUDRUN_NAME=helloworld Before running anything, authenticate and set your project: gcloud auth login gcloud config set project YOUR_PROJECT_ID Your GCP account will need a handful of IAM roles: cloudbuild.builds.editor to submit builds, storage.admin to push images to Container Registry, run.admin to deploy and manage services, and iam.serviceAccountUser so Cloud Build can act as the Cloud Run service account during deployment. If a deploy fails with a permissions error, that’s usually the first place to look. From the...

First seen: 2026-03-26 14:11

Last seen: 2026-03-26 20:15