-
Notifications
You must be signed in to change notification settings - Fork 625
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
Remove build dependencies from final image (multistage build) #1057
Conversation
Dockerfile
Outdated
@@ -9,3 +8,8 @@ RUN apk update && apk add go git gcc musl-dev ca-certificates mailcap \ | |||
&& go build -x -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge \ | |||
&& rm -rf /go \ | |||
&& apk del --purge git go gcc musl-dev | |||
|
|||
FROM alpine:edge | |||
RUN apk --no-cache add ca-certificates |
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.
RUN apk --no-cache add ca-certificates | |
RUN apk --no-cache add ca-certificates mailcap |
We need mailcap for mimetypes: see #969
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.
I was unsure if that was a build dependency or not. I'll update the branch.
Thank you, good idea! |
This multistage build takes the resulting image size down from 346MB to 90MB.
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.
Moved the mime types to the final image and the new version does not clean up in the builder as this is a redundant step as this image is dropped.
Dockerfile
Outdated
@@ -9,3 +8,8 @@ RUN apk update && apk add go git gcc musl-dev ca-certificates mailcap \ | |||
&& go build -x -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge \ | |||
&& rm -rf /go \ | |||
&& apk del --purge git go gcc musl-dev | |||
|
|||
FROM alpine:edge | |||
RUN apk --no-cache add ca-certificates |
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.
I was unsure if that was a build dependency or not. I'll update the branch.
Thanks! |
This multistage build takes the resulting image size down from 346MB to
90MB.