Článek je dostupný pouze v anglickém jazyce.

🔧 NoOps Go on Cloud Run

“There must be a standard way to package a Go container”

peto-smallPeter MalinaCTO | FlowUp

noops-go-cr-main

Every once in a while, there’s this simple thing (which then becomes monstrous and completely consumes 2 days of my work until I successfully abandon it) I really need to test. However, setting up the infrastructure is giving me headaches. Especially when googling “golang docker build” for the 100th time gives me my own article. This article shows, that building and deploying applications can be much easier than remembering Dockerfiles.

The repository for this article can be found on Github.

🎁 Building Golang Images Without a Dockerfile

“There must be a standard way to package a Go container”, I thought once. Indeed, there is, and provided directly by Google. Google ko is a lightweight tool that helps package, publish, and apply Go container images in a standard way.

Before we go any further, if you want to follow this guide:

The application we are going to build is a simple “Hello World” server using the Echo web framework. Here it goes:


Now let’s build and publish an image of this server with The tool will automatically build the binary and pack it in a minimal Docker image. Moreover, it will automatically push the image to the provided registry:

You should be seeing something like this in your output:

🚀 Launching the Application on Cloud Run

Now that we have our image in a Container Registry or Artifact Registry, Cloud Run can pull them without problems. We will be calling the gcloud SDK in the next step to create/update a Cloud Run instance:

Note that in this example,  is the name of the service I am deploying, and  needs to be replaced by the image you built in the previous step.

The resulting deployment should look something like this on your GCP:

If you’ve followed, you have just deployed your Cloud Run service without knowing nearly anything about Docker. 🎉

🚢 One-Click Build/Publish/Deploy

In case 2 commands still look like too many, you can further automate the provided commands by passing the published image right into the Cloud Run deployment command:

Last Words

I hope you enjoyed this guide. Any questions or ideas, please hit me up on my Twitter @petomalina.

Cheers,

Peter

Jsme na stejné vlně?

Kontaktujte nás

hello@flowup.cz

Kontaktujte nás prostřednictvím tohoto formuláře a my vám odpovíme e‑mailem, co nejdříve to půjde. Pokud nám ve zprávě zanecháte také své číslo, zavoláme vám. Těšíme se na vaše zprávy!

Sídlíme v Brně

Kopečná 980/43

Brno

602 00

Česká republika

map