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

Remove build dependencies from final image (multistage build) #1057

Merged
merged 1 commit into from
Mar 22, 2020

Conversation

awigen
Copy link
Contributor

@awigen awigen commented Mar 22, 2020

This multistage build takes the resulting image size down from 346MB to
90MB.

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
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
RUN apk --no-cache add ca-certificates
RUN apk --no-cache add ca-certificates mailcap

We need mailcap for mimetypes: see #969

Copy link
Contributor Author

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.

@42wim
Copy link
Owner

42wim commented Mar 22, 2020

Thank you, good idea!

This multistage build takes the resulting image size down from 346MB to
90MB.
Copy link
Contributor Author

@awigen awigen left a 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
Copy link
Contributor Author

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.

@42wim
Copy link
Owner

42wim commented Mar 22, 2020

Thanks!

@42wim 42wim merged commit 0b86b88 into 42wim:master Mar 22, 2020
@42wim 42wim added this to the 1.17.1 milestone Mar 27, 2020
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.

2 participants