Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update minimal dockerfiles to use multi-stage builds to achieve minimalness #1312

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

cyli
Copy link
Contributor

@cyli cyli commented Mar 2, 2018

Copy link
Contributor

@riyazdf riyazdf left a comment

Choose a reason for hiding this comment

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

LGTM

FROM busybox:latest
MAINTAINER David Lawrence "david.lawrence@docker.com"

# the ln is for compatibility with the docker-compose.yml, making these
# the line is for compatibility with the docker-compose.yml, making these
Copy link
Contributor

Choose a reason for hiding this comment

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

that meant ln ie the symlink

FROM busybox:latest
MAINTAINER David Lawrence "david.lawrence@docker.com"

# the ln is for compatibility with the docker-compose.yml, making these
# the line is for compatibility with the docker-compose.yml, making these
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

@justincormack
Copy link
Contributor

looks fine bar comment about comment but needs a rebase.

@cyli
Copy link
Contributor Author

cyli commented Mar 22, 2018

Thanks @justincormack! Fixed.

@@ -1,19 +1,38 @@
FROM golang:1.9.4-alpine AS build-env
RUN apk add --update git gcc libc-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

If "tiny-ness" is important; use --no-cache instead;

docker build -t before -<<EOF
FROM golang:1.9.4-alpine AS build-env
RUN apk add --update git gcc libc-dev
EOF

docker build -t after -<<EOF
FROM golang:1.9.4-alpine AS build-env
RUN apk add --no-cache git gcc libc-dev
EOF
REPOSITORY      CREATED                  SIZE
after           Less than a second ago   386MB
before          Less than a second ago   387MB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is using a build image and a final image, though - does the no-cache affect the final image? This is the before and after image built with the server.minimal.Dockerfile, without the --no-cache option and with the --no-cache option:

REPOSITORY                                       TAG                    IMAGE ID            CREATED              SIZE
<none>                                           <none>                 fa5c316b8562        17 seconds ago       540MB
after                                            latest                 f3f0621261c3        About a minute ago   21.1MB
before                                           latest                 f3f0621261c3        About a minute ago   21.1MB
<none>                                           <none>                 82a30458273b        About a minute ago   540MB

Copy link
Contributor

Choose a reason for hiding this comment

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

No it doesn't affect the final image (but does affect your local cache 😅); it was mainly a nit, and I wanted to mention --no-cache because it's awesome: it takes care of everything (updating the index, and removing it afterwards)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice! It seems to only be a MB or less, so in this case it seems ok, but I will keep that in mind for all my other images!

…alness.

Signed-off-by: cyli <cyli@twistedmatrix.com>
@endophage endophage merged commit 30aebf8 into notaryproject:master Mar 27, 2018
@cyli cyli deleted the minimal-dockerfiles branch March 27, 2018 20:35
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.

None yet

5 participants