GoLang program and Docker multi-stage builds

Julien Breux
Julien Breux’s digital life
1 min readSep 25, 2017

Introduction

When you want create a GoLang program and use it with Docker, it’s really easy! #irony

You write the code… you create a “builder container”… you create a first image with SSL certificates… you build your program using the “builder container”… and finally, you create your image by copying your program binary and using you SSL image. What???? Oo

With the new Docker multi-stage builds, you can stop to use the old builder-pattern and stop abusing make now! :)

Let’s go to the example

In this example, the program print the “hello-world” example from GitHub API.

As you can see, we only have one Dockerfile and two “FROM” instructions.

Example of Dockerfile with two FROM since Docker 17.05

That’s all folks

It’s time to write your first Go program ;)
It’s time to use Docker multi-stage builds!

Have fun!

Sources

--

--