Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Convert docker image to use alpine base #498

Merged
merged 2 commits into from
Jun 30, 2016
Merged

Conversation

Gillingham
Copy link
Contributor

@Gillingham Gillingham commented Jun 1, 2016

docker images | grep uchiwa
uchiwa alpine 8f1ecc470f0f 2 minutes ago 301 MB
uchiwa latest 1585aac90bf3 23 minutes ago 824.1 MB
Shrunk the total image size by more than half and also decreased the image build time.

For #462

docker images | grep uchiwa
uchiwa              alpine              8f1ecc470f0f        2 minutes ago       322.7 MB
uchiwa              latest              1585aac90bf3        23 minutes ago      824.1 MB
Shrunk the total image size by more than half and also decreased the
image build time.
Also add a .dockerignore file to ensure .git doesn't end up in the
image.
This reduces the built image size to 301MB, the base golang alpine image
is 225M so I think some more things can be purged but this is a huge
improvement over using the debian base.
@coveralls
Copy link

coveralls commented Jun 1, 2016

Coverage Status

Coverage remained the same at 29.094% when pulling 8bb8b93 on Gillingham:alpine into 298f525 on sensu:master.

@coveralls
Copy link

coveralls commented Jun 1, 2016

Coverage Status

Coverage remained the same at 29.094% when pulling 3f58619 on Gillingham:alpine into 298f525 on sensu:master.

@palourde
Copy link
Contributor

palourde commented Jun 8, 2016

Thank you very much for this PR! I'll have to run some tests but everything looks good, I'll try to have it merged ASAP!

@palourde palourde added this to the 0.16.1 milestone Jun 24, 2016
@palourde palourde merged commit 8bb8b93 into sensu:master Jun 30, 2016
COPY . /go/src/app
WORKDIR /go/src/app
RUN apk add --no-cache nodejs git && \
go get -d -v && \
Copy link

Choose a reason for hiding this comment

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

The go source files can be deleted after build as well. I recommend using glide or some other vendoring tool, which installs the deps into a single vendor/ directory which can be easily removed after build.

Copy link

Choose a reason for hiding this comment

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

This requires setting GOVENDOREXPERIMENT since you're still on go1.5.
Upgrading to go1.6 already has this set by default.

@oryband
Copy link

oryband commented Jun 30, 2016

uchiwa alpine 8f1ecc470f0f 2 minutes ago 301 MB
uchiwa latest 1585aac90bf3 23 minutes ago 824.1 MB

  1. in Create slim, lightweight uchiwa "binary" docker image using alpine linux #462 i mentioned the go binary takes ~50MB. Since binaries in go are (usually) contained, this is the only thing required to be in the container, along with the Node runtime and code.
  2. I guess the Node part doesn't take the remaining 250MB.
  3. So this means it's the go runtime and build dependencies that take unnecessary space.
  4. The image can be improved further by:
    1. Build the go app binary in travis or some other similar service.
    2. Copy the binary to a clean alpine image (not alpine with go).
    3. Install is the Node runtime and code in the image.

@oryband oryband mentioned this pull request Jun 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants