From 551a9d4e6186550d9d6a9445c321aa15cbb6bb7b Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 5 Sep 2024 19:28:49 +0000 Subject: [PATCH] Strip all binaries for slim images Reduces slim-bookworm image from 180M to 155M. --- 3.1/slim-bookworm/Dockerfile | 2 ++ 3.1/slim-bullseye/Dockerfile | 2 ++ 3.2/slim-bookworm/Dockerfile | 2 ++ 3.2/slim-bullseye/Dockerfile | 2 ++ 3.3/slim-bookworm/Dockerfile | 2 ++ 3.3/slim-bullseye/Dockerfile | 2 ++ 3.4-rc/slim-bookworm/Dockerfile | 2 ++ 3.4-rc/slim-bullseye/Dockerfile | 2 ++ Dockerfile.template | 6 ++++++ 9 files changed, 22 insertions(+) diff --git a/3.1/slim-bookworm/Dockerfile b/3.1/slim-bookworm/Dockerfile index 6d83ac067..136b8276b 100644 --- a/3.1/slim-bookworm/Dockerfile +++ b/3.1/slim-bookworm/Dockerfile @@ -86,9 +86,11 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ apt-mark auto '.*' > /dev/null; \ apt-mark manual $savedAptMark > /dev/null; \ diff --git a/3.1/slim-bullseye/Dockerfile b/3.1/slim-bullseye/Dockerfile index 22a77ef17..d42034cc7 100644 --- a/3.1/slim-bullseye/Dockerfile +++ b/3.1/slim-bullseye/Dockerfile @@ -86,9 +86,11 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ apt-mark auto '.*' > /dev/null; \ apt-mark manual $savedAptMark > /dev/null; \ diff --git a/3.2/slim-bookworm/Dockerfile b/3.2/slim-bookworm/Dockerfile index 5e0a6d70c..91ddbdb7b 100644 --- a/3.2/slim-bookworm/Dockerfile +++ b/3.2/slim-bookworm/Dockerfile @@ -108,10 +108,12 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ${rustArch:+--enable-yjit} \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ rm -rf /tmp/rust; \ apt-mark auto '.*' > /dev/null; \ diff --git a/3.2/slim-bullseye/Dockerfile b/3.2/slim-bullseye/Dockerfile index 9cd869858..23787a3e1 100644 --- a/3.2/slim-bullseye/Dockerfile +++ b/3.2/slim-bullseye/Dockerfile @@ -108,10 +108,12 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ${rustArch:+--enable-yjit} \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ rm -rf /tmp/rust; \ apt-mark auto '.*' > /dev/null; \ diff --git a/3.3/slim-bookworm/Dockerfile b/3.3/slim-bookworm/Dockerfile index caa2856ab..9a9ebe96b 100644 --- a/3.3/slim-bookworm/Dockerfile +++ b/3.3/slim-bookworm/Dockerfile @@ -106,10 +106,12 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ${rustArch:+--enable-yjit} \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ rm -rf /tmp/rust; \ apt-mark auto '.*' > /dev/null; \ diff --git a/3.3/slim-bullseye/Dockerfile b/3.3/slim-bullseye/Dockerfile index 33c527a4f..4e6d33958 100644 --- a/3.3/slim-bullseye/Dockerfile +++ b/3.3/slim-bullseye/Dockerfile @@ -106,10 +106,12 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ${rustArch:+--enable-yjit} \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ rm -rf /tmp/rust; \ apt-mark auto '.*' > /dev/null; \ diff --git a/3.4-rc/slim-bookworm/Dockerfile b/3.4-rc/slim-bookworm/Dockerfile index 437c092c4..1638e7e12 100644 --- a/3.4-rc/slim-bookworm/Dockerfile +++ b/3.4-rc/slim-bookworm/Dockerfile @@ -106,10 +106,12 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ${rustArch:+--enable-yjit} \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ rm -rf /tmp/rust; \ apt-mark auto '.*' > /dev/null; \ diff --git a/3.4-rc/slim-bullseye/Dockerfile b/3.4-rc/slim-bullseye/Dockerfile index bf4736f8f..e0dbdc7dd 100644 --- a/3.4-rc/slim-bullseye/Dockerfile +++ b/3.4-rc/slim-bullseye/Dockerfile @@ -106,10 +106,12 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ + debugflags='' \ ${rustArch:+--enable-yjit} \ ; \ make -j "$(nproc)"; \ make install; \ + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ \ rm -rf /tmp/rust; \ apt-mark auto '.*' > /dev/null; \ diff --git a/Dockerfile.template b/Dockerfile.template index 84b22db42..39ea2292e 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -234,12 +234,18 @@ RUN set -eux; \ --build="$gnuArch" \ --disable-install-doc \ --enable-shared \ +{{ if is_slim then ( -}} + debugflags='' \ +{{ ) else "" end -}} {{ if .rust.version then ( -}} ${rustArch:+--enable-yjit} \ {{ ) else "" end -}} ; \ make -j "$(nproc)"; \ make install; \ +{{ if is_slim then ( -}} + find /usr/local -type f -executable | xargs grep -IL . | xargs -r strip; \ +{{ ) else "" end -}} \ {{ if .rust.version then ( -}} rm -rf /tmp/rust; \