From 82cdd64bf46386712929d907625c5ed2de97aaa0 Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sat, 8 Apr 2023 17:35:36 +0200 Subject: [PATCH 1/8] Update to alpine3.17 for Dockerfile. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e4b309..de8b8db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start with a rust alpine image -FROM rust:1-alpine3.16 +FROM rust:1-alpine3.17 # 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 @@ -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.17 # if needed, install additional dependencies here RUN apk add --no-cache libgcc # copy the binary into the final image From a08641ab3ff4ef5cbc36868494afe89ef9dba30b Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 4 Jun 2023 12:40:05 +0200 Subject: [PATCH 2/8] Update README.md Adding size differences of the different Alpine versions. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c8f9cd2..1660301 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,12 @@ 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 differ in size, so make sure to test different versions if you need to optimize for size. + +alpine:3.18 8.22MB +alpine:3.17 7.95MB +alpine:3.16 5.69MB +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). From 2c032f8e706e6b1a6fdf01ec6b46894f54520aea Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 4 Jun 2023 12:42:59 +0200 Subject: [PATCH 3/8] Update README.md Creating a table for readability. --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1660301..801c6c1 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,12 @@ 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 5.69MB in the case of Alpine 3.16. Alpine versions differ in size, so make sure to test different versions if you need to optimize for size. -alpine:3.18 8.22MB -alpine:3.17 7.95MB -alpine:3.16 5.69MB -alpine:3.14 5.73MB +| Alpine | Size | +| ----------- | ------ | +| alpine:3.18 | 8.22MB | +| alpine:3.17 | 7.95MB | +| alpine:3.16 | 5.69MB | +| 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). From 7918da0629e9aa8faa959247fcc009a13e7997c5 Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 4 Jun 2023 12:45:30 +0200 Subject: [PATCH 4/8] alpine3.18 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index de8b8db..d5b4c30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start with a rust alpine image -FROM rust:1-alpine3.17 +FROM rust:1-alpine3.18 # 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 @@ -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.17 +FROM alpine:3.18 # if needed, install additional dependencies here RUN apk add --no-cache libgcc # copy the binary into the final image From bab6aff2e6e7ee1360ec4e1ef8334bd123841281 Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 7 Jan 2024 13:45:37 +0100 Subject: [PATCH 5/8] added more stats and alpine 3.19 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 801c6c1..afd0bf1 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,15 @@ 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 5.69MB in the case of Alpine 3.16. Alpine versions differ in size, so make sure to test different versions if you need to optimize for size. +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 differ in size, so make sure to test different versions if you need to optimize for size. 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). From cb4f17cfc2feea7e58d842aca50a9dc934369252 Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 7 Jan 2024 13:46:02 +0100 Subject: [PATCH 6/8] Alpine 3.19 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5b4c30..7eb2d89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start with a rust alpine image -FROM rust:1-alpine3.18 +FROM rust:1-alpine3.15 # 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 @@ -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.18 +FROM alpine:3.15 # if needed, install additional dependencies here RUN apk add --no-cache libgcc # copy the binary into the final image From 6cfc810b557128c4052e3e19d1adc58e14009fab Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 7 Jan 2024 19:03:00 +0100 Subject: [PATCH 7/8] Alpine 3.19 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7eb2d89..c3642d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start with a rust alpine image -FROM rust:1-alpine3.15 +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 @@ -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.15 +FROM alpine:3.19 # if needed, install additional dependencies here RUN apk add --no-cache libgcc # copy the binary into the final image From cb2b205382679ce9af9edc22f09de3a64553e2b9 Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Sun, 7 Jan 2024 19:08:34 +0100 Subject: [PATCH 8/8] advising against using eol alpine versions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index afd0bf1..3b7d7d4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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 5.69MB in the case of Alpine 3.16. Alpine versions differ in size, so make sure to test different versions if you need to optimize for size. Checked sizes with `docker system df -v` +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 | | ----------- | ------ |