As builders work increasingly more with containers, it’s turning into more and more necessary to scale back the time to maneuver from supply code to a deployed software. To make constructing container photos sooner and simpler, we have now constructed applied sciences like Cloud Construct, ko, Jib, Nixery and added assist for cloud-native Buildpacks. A few of these instruments focus particularly on constructing container photos instantly from the supply code and not using a Docker engine or a Dockerfile.
The Go programming language particularly makes constructing container photos from supply code a lot simpler. This text focuses on how a instrument we developed named “ko” might help you deploy providers written in Go to Cloud Run sooner than Docker construct/push, and the way it compares to options like Buildpacks.
How does ko work?
ko is an open-source instrument developed at Google that helps you construct container photos from Go packages and push them to container registries (together with Container Registry and Artifact Registry). ko does its job with out requiring you to write down a Dockerfile and even set up Docker itself in your machine.
ko is spun off of the go-containerregistry library, which helps you work together with container registries and pictures. That is for a superb cause: The vast majority of ko’s performance is applied utilizing this Go module. Most notably that is what ko does:
- Obtain a base picture from a container registry
- Statically compile your Go binary
- Create a brand new container picture layer with the Go binary
- Append that layer to the bottom picture to create a brand new picture
- Push the brand new picture to the distant container registry
Constructing and pushing a container picture from a Go program is kind of easy with ko: