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 to Alpine Linux 3.19 and improved README to show size differences for alpine versions. #15

Merged
merged 8 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start with a rust alpine image
FROM rust:1-alpine3.16
FROM rust:1-alpine3.19
# This is important, see https://github.com/rust-lang/docker-rust/issues/85
ENV RUSTFLAGS="-C target-feature=-crt-static"
# if needed, add additional dependencies here
Expand All @@ -12,7 +12,7 @@ RUN cargo build --release
RUN strip target/release/mini-docker-rust

# use a plain alpine image, the alpine version needs to match the builder
FROM alpine:3.16
FROM alpine:3.19
# if needed, install additional dependencies here
RUN apk add --no-cache libgcc
# copy the binary into the final image
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

Very small rust docker image.

This is an example project on how to build very small docker images for a rust project. The resulting image for a working hello world was about 6.01MB during my tests.
This is an example project on how to build very small docker images for a rust project. The resulting image for a working `hello world` was 5.69MB in the case of Alpine 3.16. Alpine versions have changed in size with past releases (see below a table with historic sizes of the docker images). Using end-of-life Alpine/Rust releases is not advised (even if they might be slightly smaller). Checked sizes with `docker system df -v`

| Alpine | Size |
| ----------- | ------ |
| alpine:3.19 | 8.22MB |
| alpine:3.18 | 8.22MB |
| alpine:3.17 | 7.95MB |
| alpine:3.16 | 5.69MB |
| alpine:3.15 | 5.74MB |
| alpine:3.14 | 5.73MB |

This repo is trying to keep the docker overhead to a minimum without sacrificing performance or the usability implications of using `FROM scratch`. If you want to reduce the binary size further you might be interested in [johnthagen/min-sized-rust](https://github.com/johnthagen/min-sized-rust).

Expand Down
Loading