Skip to content

🐋 Example of a multi-stage golang build, with a run container ‘from scratch’

License

Notifications You must be signed in to change notification settings

jhermann/docker-golang-hi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-golang-hi

Name

jhermann/gohi

Description

A golang multi-stage build container image example.

Maintainer

Jürgen Hermann <jh@web.de>

The following commands build and run a golang binary from the source in hi.go, putting it into a from-scratch Docker image.

docker build -t jhermann/gohi -t jhermann/gohi:$(git describe --tags) .
docker run --rm -it jhermann/gohi

It doesn't get easier than this. ☺

The resulting image is only slightly larger than the contained golang binary.

$ dockviz images --tree jhermann/gohi
└─927b6ad2e4fa Virtual Size: 1.4 MB Tags: jhermann/gohi:latest, jhermann/gohi:v0-1-g93bf073

To look at the image's metadata, use docker inspect:

docker inspect jhermann/gohi:latest | jq -CS

Leave out the jq part if you don't have that installed, it just colorizes the output.

Using prom/busybox:glibc instead of scratch adds 6 MB in size, a shell, and the other debugging and introspection conveniences of a full base image.

About

🐋 Example of a multi-stage golang build, with a run container ‘from scratch’

Resources

License

Stars

Watchers

Forks

Packages

No packages published