From 156a7aab47eb98b647f2f46fcd31b3922ab879ce 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.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/slim-bookworm/Dockerfile | 2 ++ 3.4/slim-bullseye/Dockerfile | 2 ++ 3.5-rc/slim-bookworm/Dockerfile | 2 ++ 3.5-rc/slim-bullseye/Dockerfile | 2 ++ Dockerfile.template | 6 ++++++ 9 files changed, 22 insertions(+) diff --git a/3.2/slim-bookworm/Dockerfile b/3.2/slim-bookworm/Dockerfile index b7057d03c..249a7a706 100644 --- a/3.2/slim-bookworm/Dockerfile +++ b/3.2/slim-bookworm/Dockerfile @@ -95,9 +95,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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 76afd63c5..84dda798f 100644 --- a/3.2/slim-bullseye/Dockerfile +++ b/3.2/slim-bullseye/Dockerfile @@ -95,9 +95,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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 1ee20ce46..e211ce764 100644 --- a/3.3/slim-bookworm/Dockerfile +++ b/3.3/slim-bookworm/Dockerfile @@ -93,9 +93,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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 e1291c858..c2f05aaf9 100644 --- a/3.3/slim-bullseye/Dockerfile +++ b/3.3/slim-bullseye/Dockerfile @@ -93,9 +93,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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/slim-bookworm/Dockerfile b/3.4/slim-bookworm/Dockerfile index 935df7aff..166f6eaa9 100644 --- a/3.4/slim-bookworm/Dockerfile +++ b/3.4/slim-bookworm/Dockerfile @@ -93,9 +93,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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/slim-bullseye/Dockerfile b/3.4/slim-bullseye/Dockerfile index 31cdaaaf2..09bb80269 100644 --- a/3.4/slim-bullseye/Dockerfile +++ b/3.4/slim-bullseye/Dockerfile @@ -93,9 +93,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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.5-rc/slim-bookworm/Dockerfile b/3.5-rc/slim-bookworm/Dockerfile index 7604e847c..0f50af103 100644 --- a/3.5-rc/slim-bookworm/Dockerfile +++ b/3.5-rc/slim-bookworm/Dockerfile @@ -93,9 +93,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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.5-rc/slim-bullseye/Dockerfile b/3.5-rc/slim-bullseye/Dockerfile index d538daea2..42cd488d7 100644 --- a/3.5-rc/slim-bullseye/Dockerfile +++ b/3.5-rc/slim-bullseye/Dockerfile @@ -93,9 +93,11 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ + debugflags='' \ ; \ 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 9f9a68542..70ea4d4b5 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -207,9 +207,15 @@ RUN set -eux; \ --disable-install-doc \ --enable-shared \ ${rustArch:+--enable-yjit} \ +{{ if is_slim then ( -}} + debugflags='' \ +{{ ) 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 -}} \ rm -rf /tmp/rust; \ {{ if is_alpine then ( -}}