-
Notifications
You must be signed in to change notification settings - Fork 514
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
FROM golang:1.9.4-alpine AS build-env | ||
RUN apk add --update git gcc libc-dev | ||
# Pin to the specific v3.0.0 version | ||
RUN go get -tags 'mysql postgres file' github.com/mattes/migrate/cli && mv /go/bin/cli /go/bin/migrate | ||
|
||
ENV NOTARYPKG github.com/theupdateframework/notary | ||
|
||
# Copy the local repo to the expected go path | ||
COPY . /go/src/${NOTARYPKG} | ||
WORKDIR /go/src/${NOTARYPKG} | ||
|
||
# Build notary-server | ||
RUN go install \ | ||
-tags pkcs11 \ | ||
-ldflags "-w -X ${NOTARYPKG}/version.GitCommit=`git rev-parse --short HEAD` -X ${NOTARYPKG}/version.NotaryVersion=`cat NOTARY_VERSION`" \ | ||
${NOTARYPKG}/cmd/notary-server | ||
|
||
|
||
FROM busybox:latest | ||
MAINTAINER David Lawrence "david.lawrence@docker.com" | ||
|
||
# the ln is for compatibility with the docker-compose.yml, making these | ||
# images a straight swap for the those built in the compose file. | ||
RUN mkdir -p /usr/bin /var/lib && ln -s /bin/env /usr/bin/env | ||
|
||
COPY ./bin/notary-server /usr/bin/notary-server | ||
COPY ./bin/migrate /usr/bin/migrate | ||
COPY ./bin/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1 | ||
COPY ./fixtures /var/lib/notary/fixtures | ||
COPY ./migrations /var/lib/notary/migrations | ||
COPY --from=build-env /go/bin/notary-server /usr/bin/notary-server | ||
COPY --from=build-env /go/bin/migrate /usr/bin/migrate | ||
COPY --from=build-env /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1 | ||
COPY --from=build-env /go/src/github.com/theupdateframework/notary/migrations/ /var/lib/notary/migrations | ||
COPY --from=build-env /go/src/github.com/theupdateframework/notary/fixtures /var/lib/notary/fixtures | ||
RUN chmod 0600 /var/lib/notary/fixtures/database/* | ||
|
||
WORKDIR /var/lib/notary | ||
# SERVICE_NAME needed for migration script | ||
ENV SERVICE_NAME=notary_server | ||
EXPOSE 4443 | ||
|
||
ENTRYPOINT [ "/usr/bin/notary-server" ] | ||
CMD [ "-config=/var/lib/notary/fixtures/server-config-local.json" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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;There was a problem hiding this comment.
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:There was a problem hiding this comment.
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)There was a problem hiding this comment.
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!