Skip to content

Commit

Permalink
Merge pull request #15 from parasew/patch-7
Browse files Browse the repository at this point in the history
Update to Alpine Linux 3.19 and improved README to show size differences for alpine versions.
  • Loading branch information
kpcyrd authored Jan 7, 2024
2 parents f24499e + cb2b205 commit 1ed9d27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit 1ed9d27

Please sign in to comment.