Skip to content

docker: switch to multistage build#22

Merged
shrayolacrayon merged 1 commit intomasterfrom
dockerfile-optimization
Aug 23, 2018
Merged

docker: switch to multistage build#22
shrayolacrayon merged 1 commit intomasterfrom
dockerfile-optimization

Conversation

@mccutchen
Copy link
Copy Markdown
Contributor

This results in a minimal final image without the full golang runtime, addressing #20.

RFR @loganmeetsworld @shrayolacrayon
cc @danbf

Comment thread Godeps
github.com/18F/hmacauth 1.0.1
gopkg.in/yaml.v2 v2
github.com/imdario/mergo v0.3.4
github.com/BurntSushi/toml d94612f9fc140360834f9742158c70b5c5b5535b
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought we'd already removed this!

Copy link
Copy Markdown
Contributor

@loganmeetsworld loganmeetsworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @mccutchen!

@mccutchen
Copy link
Copy Markdown
Contributor Author

Size difference, for posterity:

$ docker image list | grep sso
sso                             master              57eb2a5f0f46        About a minute ago       1.13GB
sso                             alpine              cc20033f631e        10 minutes ago           26.3MB

Went from 1.13GB to 26.3MB!

@mccutchen
Copy link
Copy Markdown
Contributor Author

Check latest commit, we need to add the ca-certificates package to the final image. Without it, we get an error trying to talk to Google:

{"error":"Post https://www.googleapis.com/oauth2/v3/token: x509: failed to load system roots and no roots provided","level":"error","msg":"error redeeming authentication code","remote_address":"172.20.0.1","service":"sso-auth","time":"2018-08-23 00:57:22.82312"}

@mccutchen
Copy link
Copy Markdown
Contributor Author

Another update: Apparently something about the alpine image prevents the pure Go DNS resolver from properly reading /etc/hosts, which breaks the quick start:
https://groups.google.com/d/msg/golang-nuts/G-faJ0bthz0/Lx-MsDIOCAAJ

Now we've updated to debian:stable-slim instead of alpine:3.8 for the base image, bringing our final image size up to 83MB:

sso                             debian              888f18f0bcc5        39 seconds ago      83.5MB

@danbf
Copy link
Copy Markdown
Contributor

danbf commented Aug 23, 2018

wow, great size savings!

@loganmeetsworld
Copy link
Copy Markdown
Contributor

Just one request: Can we squash the commits or rephrase the last two commits to give a little more context?

@mccutchen
Copy link
Copy Markdown
Contributor Author

mccutchen commented Aug 23, 2018 via email

This results in a minimal final image without the full golang runtime.
We settled on debian:stable-slim for the final base image because of
issues with alpine and the Go native DNS resolver ignoring /etc/hosts,
which can cause problems for some deployment approaches.
@mccutchen
Copy link
Copy Markdown
Contributor Author

@loganmeetsworld squashed!

@shrayolacrayon shrayolacrayon merged commit f140940 into master Aug 23, 2018
@shrayolacrayon shrayolacrayon deleted the dockerfile-optimization branch August 23, 2018 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants