From 7dc395a6b9fabce8685009dc385fa98f8a944d5c Mon Sep 17 00:00:00 2001 From: Shawn McElroy Date: Wed, 13 May 2020 12:39:44 -0700 Subject: [PATCH 1/2] add LDFLAGS for optimizing image size --- 3.5/alpine3.10/Dockerfile | 1 + 3.5/alpine3.11/Dockerfile | 1 + 3.6/alpine3.10/Dockerfile | 1 + 3.6/alpine3.11/Dockerfile | 1 + 3.7/alpine3.10/Dockerfile | 1 + 3.7/alpine3.11/Dockerfile | 1 + 3.8/alpine3.10/Dockerfile | 1 + 3.8/alpine3.11/Dockerfile | 1 + 3.9-rc/alpine3.11/Dockerfile | 1 + Dockerfile-alpine.template | 1 + 10 files changed, 10 insertions(+) diff --git a/3.5/alpine3.10/Dockerfile b/3.5/alpine3.10/Dockerfile index 016275248..89904f7d3 100644 --- a/3.5/alpine3.10/Dockerfile +++ b/3.5/alpine3.10/Dockerfile @@ -78,6 +78,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.5/alpine3.11/Dockerfile b/3.5/alpine3.11/Dockerfile index 44dd21192..a7aae3997 100644 --- a/3.5/alpine3.11/Dockerfile +++ b/3.5/alpine3.11/Dockerfile @@ -78,6 +78,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.6/alpine3.10/Dockerfile b/3.6/alpine3.10/Dockerfile index 277158f5c..859e6959f 100644 --- a/3.6/alpine3.10/Dockerfile +++ b/3.6/alpine3.10/Dockerfile @@ -80,6 +80,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.6/alpine3.11/Dockerfile b/3.6/alpine3.11/Dockerfile index 8f65e02a4..bf6f63838 100644 --- a/3.6/alpine3.11/Dockerfile +++ b/3.6/alpine3.11/Dockerfile @@ -80,6 +80,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.7/alpine3.10/Dockerfile b/3.7/alpine3.10/Dockerfile index 4918fc2e5..ffb52cd82 100644 --- a/3.7/alpine3.10/Dockerfile +++ b/3.7/alpine3.10/Dockerfile @@ -81,6 +81,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.7/alpine3.11/Dockerfile b/3.7/alpine3.11/Dockerfile index 0beccae5f..fb0038aee 100644 --- a/3.7/alpine3.11/Dockerfile +++ b/3.7/alpine3.11/Dockerfile @@ -81,6 +81,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.8/alpine3.10/Dockerfile b/3.8/alpine3.10/Dockerfile index c52031986..96f5b0e03 100644 --- a/3.8/alpine3.10/Dockerfile +++ b/3.8/alpine3.10/Dockerfile @@ -81,6 +81,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ && make install \ \ && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ diff --git a/3.8/alpine3.11/Dockerfile b/3.8/alpine3.11/Dockerfile index afa9d431f..d0734559f 100644 --- a/3.8/alpine3.11/Dockerfile +++ b/3.8/alpine3.11/Dockerfile @@ -81,6 +81,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ && make install \ \ && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ diff --git a/3.9-rc/alpine3.11/Dockerfile b/3.9-rc/alpine3.11/Dockerfile index 07e8b5234..dd1d8dc18 100644 --- a/3.9-rc/alpine3.11/Dockerfile +++ b/3.9-rc/alpine3.11/Dockerfile @@ -81,6 +81,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ && make install \ \ && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 6296ad5db..27ca1d4d2 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -75,6 +75,7 @@ RUN set -ex \ # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ From 6a981ebc3ba38d0668db58813f309e58763438e1 Mon Sep 17 00:00:00 2001 From: Shawn McElroy Date: Fri, 15 May 2020 12:59:25 -0700 Subject: [PATCH 2/2] also should apply to slim images. --- 3.5/buster/slim/Dockerfile | 1 + 3.5/stretch/slim/Dockerfile | 1 + 3.6/buster/slim/Dockerfile | 1 + 3.6/stretch/slim/Dockerfile | 1 + 3.7/buster/slim/Dockerfile | 1 + 3.7/stretch/slim/Dockerfile | 1 + 3.8/buster/slim/Dockerfile | 1 + Dockerfile-slim.template | 1 + 8 files changed, 8 insertions(+) diff --git a/3.5/buster/slim/Dockerfile b/3.5/buster/slim/Dockerfile index 32e25ef39..0b0afd660 100644 --- a/3.5/buster/slim/Dockerfile +++ b/3.5/buster/slim/Dockerfile @@ -70,6 +70,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.5/stretch/slim/Dockerfile b/3.5/stretch/slim/Dockerfile index 29232d814..4ba242cc2 100644 --- a/3.5/stretch/slim/Dockerfile +++ b/3.5/stretch/slim/Dockerfile @@ -70,6 +70,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.6/buster/slim/Dockerfile b/3.6/buster/slim/Dockerfile index 6f0f40b07..47ffb2e4c 100644 --- a/3.6/buster/slim/Dockerfile +++ b/3.6/buster/slim/Dockerfile @@ -70,6 +70,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.6/stretch/slim/Dockerfile b/3.6/stretch/slim/Dockerfile index 423e0fff6..209eb24c9 100644 --- a/3.6/stretch/slim/Dockerfile +++ b/3.6/stretch/slim/Dockerfile @@ -70,6 +70,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.7/buster/slim/Dockerfile b/3.7/buster/slim/Dockerfile index db846b867..9ee8e5081 100644 --- a/3.7/buster/slim/Dockerfile +++ b/3.7/buster/slim/Dockerfile @@ -71,6 +71,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.7/stretch/slim/Dockerfile b/3.7/stretch/slim/Dockerfile index 245229ee2..437fffef6 100644 --- a/3.7/stretch/slim/Dockerfile +++ b/3.7/stretch/slim/Dockerfile @@ -71,6 +71,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \ diff --git a/3.8/buster/slim/Dockerfile b/3.8/buster/slim/Dockerfile index 935649c91..5789bf382 100644 --- a/3.8/buster/slim/Dockerfile +++ b/3.8/buster/slim/Dockerfile @@ -71,6 +71,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ && make install \ && ldconfig \ \ diff --git a/Dockerfile-slim.template b/Dockerfile-slim.template index 3d0c35933..457f865d6 100644 --- a/Dockerfile-slim.template +++ b/Dockerfile-slim.template @@ -65,6 +65,7 @@ RUN set -ex \ --with-system-ffi \ --without-ensurepip \ && make -j "$(nproc)" \ + LDFLAGS="-Wl,--strip-all" \ # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 PROFILE_TASK='-m test.regrtest --pgo \ test_array \