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

Reduce Docker image size #24

Merged
merged 1 commit into from
Apr 11, 2022
Merged

Reduce Docker image size #24

merged 1 commit into from
Apr 11, 2022

Conversation

dmke
Copy link
Contributor

@dmke dmke commented Apr 4, 2022

By using Alpine instead of Ubuntu, the resulting image is around 110 MB smaller:

$ docker images
REPOSITORY       TAG      CREATED         SIZE
unms-exporter    alpine   3 seconds ago   20MB
unms-exporter    ubuntu   5 minutes ago   132MB

Some savings are due to building with -ldflags="-s -w" (strip binary), and -trimpath (remove builder path prefixes).

We could save 5 MB more by using FROM scratch instead of Alpine, but then handling of timezone and CA certificate files becomes a hassle.

mraerino
mraerino previously approved these changes Apr 8, 2022
Copy link
Member

@mraerino mraerino left a comment

Choose a reason for hiding this comment

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

cool, that makes sense. Thanks!

@mraerino
Copy link
Member

mraerino commented Apr 8, 2022

give me a sec to fix the CI flow for external contributions

@mraerino
Copy link
Member

mraerino commented Apr 8, 2022

@dmke would you mind merging main into your branch so the CI can run?

By using Alpine instead of Ubuntu, the resulting image is around
110 MB smaller:

    $ docker images
    REPOSITORY       TAG      CREATED         SIZE
    unms-exporter    alpine   3 seconds ago   20MB
    unms-exporter    ubuntu   5 minutes ago   132MB

We could save 5 MB more by using `FROM scratch` instead of Alpine,
but then handling of timezone and CA certificate files becomes a
hassle.
@dmke
Copy link
Contributor Author

dmke commented Apr 9, 2022

Done.

@mraerino mraerino enabled auto-merge (squash) April 11, 2022 15:09
@mraerino mraerino disabled auto-merge April 11, 2022 15:09
@mraerino mraerino merged commit 9c2efb6 into ffddorf:main Apr 11, 2022
@dmke dmke deleted the docker/alpine branch April 11, 2022 19:26
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