Skip to content

Commit ee03bff

Browse files
authored
Merge pull request #1868 from mayeut/image-size
chore: reduce image size
2 parents a8bb7dc + ed0e54b commit ee03bff

File tree

4 files changed

+50
-49
lines changed

4 files changed

+50
-49
lines changed

docker/Dockerfile

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,120 +34,115 @@ COPY build_scripts/fixup-mirrors.sh /usr/local/sbin/fixup-mirrors
3434
COPY build_scripts/install-entrypoint.sh \
3535
build_scripts/update-system-packages.sh \
3636
build_scripts/build_utils.sh \
37-
/build_scripts/
37+
/opt/_internal/build_scripts/
3838

39-
RUN /build_scripts/install-entrypoint.sh && rm -rf /build_scripts
39+
RUN /opt/_internal/build_scripts/install-entrypoint.sh
4040
COPY manylinux-entrypoint /usr/local/bin/manylinux-entrypoint
4141
ENTRYPOINT ["manylinux-entrypoint"]
4242

43-
COPY build_scripts/install-runtime-packages.sh \
44-
build_scripts/update-system-packages.sh \
45-
build_scripts/build_utils.sh \
46-
/build_scripts/
47-
RUN manylinux-entrypoint /build_scripts/install-runtime-packages.sh && rm -rf /build_scripts/
48-
49-
COPY build_scripts/build_utils.sh /build_scripts/
43+
COPY build_scripts/install-runtime-packages.sh /opt/_internal/build_scripts/
44+
RUN manylinux-entrypoint /opt/_internal/build_scripts/install-runtime-packages.sh
5045

5146

5247
# prepare cross-compilation support
5348
FROM --platform=linux/${MANYLINUX_BUILDARCH} ghcr.io/mayeut/static-clang:${MANYLINUX_CLANG_VERSION} AS static_clang_bin
5449
FROM runtime_base_packages AS static_clang_prepare
5550
ARG MANYLINUX_DISABLE_CLANG
56-
COPY build_scripts/install-clang-static.sh /build_scripts/
51+
COPY build_scripts/install-clang-static.sh /opt/_internal/build_scripts/
5752
RUN --mount=type=bind,target=/clang,from=static_clang_bin \
5853
mkdir -p /tmp/cross-compiler && \
5954
cp -rf /clang/opt/clang/* /tmp/cross-compiler/ && \
60-
/build_scripts/install-clang-static.sh /tmp/cross-compiler
55+
/opt/_internal/build_scripts/install-clang-static.sh /tmp/cross-compiler
6156
FROM scratch AS static_clang
6257
COPY --from=static_clang_prepare /tmp/cross-compiler /
6358

6459

6560
FROM runtime_base_packages AS runtime_base
66-
COPY build_scripts/install-autoconf.sh /build_scripts/
61+
COPY build_scripts/install-autoconf.sh /opt/_internal/build_scripts/
6762
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
6863
export AUTOCONF_ROOT=autoconf-2.72 && \
6964
export AUTOCONF_HASH=afb181a76e1ee72832f6581c0eddf8df032b83e2e0239ef79ebedc4467d92d6e && \
7065
export AUTOCONF_DOWNLOAD_URL=https://ftpmirror.gnu.org/gnu/autoconf && \
71-
/tmp/cross-compiler/entrypoint /build_scripts/install-autoconf.sh
66+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/install-autoconf.sh
7267

73-
COPY build_scripts/install-automake.sh /build_scripts/
68+
COPY build_scripts/install-automake.sh /opt/_internal/build_scripts/
7469
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
7570
export AUTOMAKE_ROOT=automake-1.18.1 && \
7671
export AUTOMAKE_HASH=63e585246d0fc8772dffdee0724f2f988146d1a3f1c756a3dc5cfbefa3c01915 && \
7772
export AUTOMAKE_DOWNLOAD_URL=https://ftpmirror.gnu.org/gnu/automake && \
78-
/tmp/cross-compiler/entrypoint /build_scripts/install-automake.sh
73+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/install-automake.sh
7974

80-
COPY build_scripts/install-libtool.sh /build_scripts/
75+
COPY build_scripts/install-libtool.sh /opt/_internal/build_scripts/
8176
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
8277
export LIBTOOL_ROOT=libtool-2.5.4 && \
8378
export LIBTOOL_HASH=da8ebb2ce4dcf46b90098daf962cffa68f4b4f62ea60f798d0ef12929ede6adf && \
8479
export LIBTOOL_DOWNLOAD_URL=https://ftpmirror.gnu.org/gnu/libtool && \
85-
/tmp/cross-compiler/entrypoint /build_scripts/install-libtool.sh
80+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/install-libtool.sh
8681

87-
COPY build_scripts/install-libxcrypt.sh /build_scripts/
82+
COPY build_scripts/install-libxcrypt.sh /opt/_internal/build_scripts/
8883
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
8984
export LIBXCRYPT_VERSION=4.5.1 && \
9085
export LIBXCRYPT_HASH=e9b46a62397c15372935f6a75dc3929c62161f2620be7b7f57f03d69102c1a86 && \
9186
export LIBXCRYPT_DOWNLOAD_URL=https://github.com/besser82/libxcrypt/releases/download && \
92-
/tmp/cross-compiler/entrypoint /build_scripts/install-libxcrypt.sh
87+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/install-libxcrypt.sh
9388

9489

9590
FROM runtime_base AS build_base
96-
COPY build_scripts/install-build-packages.sh /build_scripts/
97-
RUN manylinux-entrypoint /build_scripts/install-build-packages.sh
91+
COPY build_scripts/install-build-packages.sh /opt/_internal/build_scripts/
92+
RUN manylinux-entrypoint /opt/_internal/build_scripts/install-build-packages.sh
9893

9994

10095
FROM build_base AS build_git
101-
COPY build_scripts/build-curl.sh /build_scripts/
96+
COPY build_scripts/build-curl.sh /opt/_internal/build_scripts/
10297
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
10398
export CURL_ROOT=curl-8.17.0 && \
10499
export CURL_HASH=e8e74cdeefe5fb78b3ae6e90cd542babf788fa9480029cfcee6fd9ced42b7910 && \
105100
export CURL_DOWNLOAD_URL=https://curl.haxx.se/download && \
106-
/tmp/cross-compiler/entrypoint /build_scripts/build-curl.sh
107-
COPY build_scripts/build-git.sh /build_scripts/
101+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-curl.sh
102+
COPY build_scripts/build-git.sh /opt/_internal/build_scripts/
108103
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
109104
export GIT_ROOT=git-2.51.2 && \
110105
export GIT_HASH=9b44c2b337ec838e10aad42439d390963904449710d30c9e7e4ba449f45da98f && \
111106
export GIT_DOWNLOAD_URL=https://www.kernel.org/pub/software/scm/git && \
112-
/tmp/cross-compiler/entrypoint /build_scripts/build-git.sh
107+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-git.sh
113108

114109

115110
FROM build_base AS build_sqlite3
116-
COPY build_scripts/build-sqlite3.sh /build_scripts/
111+
COPY build_scripts/build-sqlite3.sh /opt/_internal/build_scripts/
117112
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
118113
export SQLITE_AUTOCONF_ROOT=sqlite-autoconf-3510000 && \
119114
export SQLITE_AUTOCONF_HASH=42e26dfdd96aa2e6b1b1be5c88b0887f9959093f650d693cb02eb9c36d146ca5 && \
120115
export SQLITE_AUTOCONF_DOWNLOAD_URL=https://www.sqlite.org/2025 && \
121-
/tmp/cross-compiler/entrypoint /build_scripts/build-sqlite3.sh
116+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-sqlite3.sh
122117

123118

124119
FROM build_base AS build_tcl_tk
125-
COPY build_scripts/build-tcltk.sh /build_scripts/
120+
COPY build_scripts/build-tcltk.sh /opt/_internal/build_scripts/
126121
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
127122
export TCL_ROOT=tcl8.6.17 && \
128123
export TCL_HASH=a3903371efcce8a405c5c245d029e9f6850258a60fa3761c4d58995610949b31 && \
129124
export TCL_DOWNLOAD_URL=https://prdownloads.sourceforge.net/tcl && \
130125
export TK_ROOT=tk8.6.17 && \
131126
export TK_HASH=e4982df6f969c08bf9dd858a6891059b4a3f50dc6c87c10abadbbe2fc4838946 && \
132-
/tmp/cross-compiler/entrypoint /build_scripts/build-tcltk.sh
127+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-tcltk.sh
133128

134129

135130
FROM build_base AS build_mpdecimal
136-
COPY build_scripts/build-mpdecimal.sh /build_scripts/
131+
COPY build_scripts/build-mpdecimal.sh /opt/_internal/build_scripts/
137132
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
138133
export MPDECIMAL_ROOT=mpdecimal-4.0.1 && \
139134
export MPDECIMAL_HASH=96d33abb4bb0070c7be0fed4246cd38416188325f820468214471938545b1ac8 && \
140135
export MPDECIMAL_DOWNLOAD_URL=https://www.bytereef.org/software/mpdecimal/releases && \
141-
/tmp/cross-compiler/entrypoint /build_scripts/build-mpdecimal.sh
136+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-mpdecimal.sh
142137

143138

144139
FROM build_base AS build_zstd
145-
COPY build_scripts/build-zstd.sh /build_scripts/
140+
COPY build_scripts/build-zstd.sh /opt/_internal/build_scripts/
146141
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
147142
export ZSTD_VERSION=1.5.7 && \
148143
export ZSTD_HASH=eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3 && \
149144
export ZSTD_DOWNLOAD_URL=https://github.com/facebook/zstd/releases/download && \
150-
/tmp/cross-compiler/entrypoint /build_scripts/build-zstd.sh
145+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-zstd.sh
151146

152147

153148
FROM --platform=${BUILDPLATFORM} ghcr.io/sigstore/cosign/cosign:v${MANYLINUX_COSIGN_VERSION} AS cosign-bin
@@ -159,60 +154,60 @@ COPY --from=build_mpdecimal /manylinux-buildfs /
159154
COPY --from=build_zstd /manylinux-buildfs /
160155
COPY --from=build_sqlite3 /manylinux-buildfs /
161156
RUN if command -v apk >/dev/null 2>&1; then ldconfig /; else ldconfig; fi
162-
COPY build_scripts/build-openssl.sh /build_scripts/
157+
COPY build_scripts/build-openssl.sh /opt/_internal/build_scripts/
163158
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
164159
export OPENSSL_ROOT=openssl-3.5.4 && \
165160
export OPENSSL_HASH=967311f84955316969bdb1d8d4b983718ef42338639c621ec4c34fddef355e99 && \
166161
export OPENSSL_DOWNLOAD_URL=https://github.com/openssl/openssl/releases/download/${OPENSSL_ROOT} && \
167-
/tmp/cross-compiler/entrypoint /build_scripts/build-openssl.sh
162+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-openssl.sh
168163
COPY --from=cosign-bin /ko-app/cosign /usr/local/bin/cosign
169-
COPY build_scripts/build-cpython.sh /build_scripts/
164+
COPY build_scripts/build-cpython.sh /opt/_internal/build_scripts/
170165

171166

172167
FROM build_cpython AS build_cpython38
173168
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
174169
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
175-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh lukasz@langa.pl https://github.com/login/oauth 3.8.20
170+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh lukasz@langa.pl https://github.com/login/oauth 3.8.20
176171

177172
FROM build_cpython AS build_cpython39
178173
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
179174
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
180-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh lukasz@langa.pl https://github.com/login/oauth 3.9.25
175+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh lukasz@langa.pl https://github.com/login/oauth 3.9.25
181176

182177
FROM build_cpython AS build_cpython310
183178
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
184179
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
185-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh pablogsal@python.org https://accounts.google.com 3.10.19
180+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh pablogsal@python.org https://accounts.google.com 3.10.19
186181

187182
FROM build_cpython AS build_cpython311
188183
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
189184
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
190-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh pablogsal@python.org https://accounts.google.com 3.11.14
185+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh pablogsal@python.org https://accounts.google.com 3.11.14
191186

192187
FROM build_cpython AS build_cpython312
193188
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
194189
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
195-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh thomas@python.org https://accounts.google.com 3.12.12
190+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh thomas@python.org https://accounts.google.com 3.12.12
196191

197192
FROM build_cpython AS build_cpython313
198193
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
199194
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
200-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh thomas@python.org https://accounts.google.com 3.13.9
195+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh thomas@python.org https://accounts.google.com 3.13.9
201196

202197
FROM build_cpython AS build_cpython313_nogil
203198
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
204199
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
205-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh thomas@python.org https://accounts.google.com 3.13.9 nogil
200+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh thomas@python.org https://accounts.google.com 3.13.9 nogil
206201

207202
FROM build_cpython AS build_cpython314
208203
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
209204
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
210-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh hugo@python.org https://github.com/login/oauth 3.14.0
205+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh hugo@python.org https://github.com/login/oauth 3.14.0
211206

212207
FROM build_cpython AS build_cpython314_nogil
213208
ARG MANYLINUX_DISABLE_CLANG_FOR_CPYTHON
214209
RUN --mount=type=bind,from=static_clang,target=/tmp/cross-compiler,ro \
215-
/tmp/cross-compiler/entrypoint /build_scripts/build-cpython.sh hugo@python.org https://github.com/login/oauth 3.14.0 nogil
210+
/tmp/cross-compiler/entrypoint /opt/_internal/build_scripts/build-cpython.sh hugo@python.org https://github.com/login/oauth 3.14.0 nogil
216211

217212

218213
FROM runtime_base

docker/build_scripts/build_utils.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ function manylinux_pkg_clean {
120120
if [ "${PACKAGE_MANAGER}" = "yum" ]; then
121121
yum clean all
122122
rm -rf /var/cache/yum
123+
if [ -f /var/log/anaconda/journal.log ]; then
124+
rm /var/log/anaconda/journal.log
125+
fi
126+
if [ -d /var/lib/yum/history ]; then
127+
rm -rf /var/lib/yum/history
128+
fi
123129
elif [ "${PACKAGE_MANAGER}" = "dnf" ]; then
124130
dnf clean all
125131
rm -rf /var/cache/dnf

docker/build_scripts/update-system-packages.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ if [ -d /usr/local/share/locale ]; then
6464
find /usr/local/share/locale -mindepth 1 -maxdepth 1 -not \( -name 'en*' -or -name 'locale.alias' \) -print0 | xargs -0 rm -rf
6565
fi
6666

67-
# Fix libc headers to remain compatible with C99 compilers.
68-
find /usr/include/ -type f -exec sed -i 's/\bextern _*inline_*\b/extern __inline __attribute__ ((__gnu_inline__))/g' {} +
69-
7067
if [ "${DEVTOOLSET_ROOTPATH:-}" != "" ]; then
7168
# remove useless things that have been installed/updated by devtoolset
7269
if [ -d "${DEVTOOLSET_ROOTPATH}/usr/share/man" ]; then

docker/tests/modules-check.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ def test_sqlite3(self):
1616
# When the extension is not installed, it raises:
1717
# sqlite3.OperationalError: no such module: fts5
1818
conn = sqlite3.connect(":memory:")
19-
conn.execute("create virtual table fts5test using fts5 (data);")
19+
try:
20+
conn.execute("create virtual table fts5test using fts5 (data);")
21+
finally:
22+
conn.close()
2023

2124
def test_tkinter(self):
2225
# Make sure tkinter module can be loaded properly

0 commit comments

Comments
 (0)