Skip to content

Commit 3626da5

Browse files
committed
[manylinux2010] Reduce image size
Final image size is now built from scratch because almost everything gets replaced in the base centos:6 image which means it's useless to pull this base image as it will not help with caching but just increase storage/bandwidth requirements when the host does not use centos:6 base image for other images => 384 MB (including centos:6, 194MB) -> 200MB
1 parent d92da2e commit 3626da5

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
script:
6565
- PLATFORM=$PLATFORM docker/glibc/build.sh all
6666
before_cache:
67-
- travis-ci/cache_images.sh combined
67+
- travis-ci/cache_images.sh combined_build
6868
- <<: *manylinux-build
6969
env:
7070
- PLATFORM="x86_64"

docker/glibc/Dockerfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
FROM centos:6
2-
LABEL maintainer="The Manylinux project"
1+
FROM centos:6 AS manylinux2010_centos-6-no-vsyscall-build
32

43
# do not install debuginfo and what x86_64 already provides
54
COPY --from=quay.io/pypa/manylinux2010_centos-6-with-vsyscall32:latest \
@@ -32,10 +31,22 @@ RUN sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf &&
3231
sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/*.repo && \
3332
sed -i 's;^#baseurl=http://mirror;baseurl=https://vault;g' /etc/yum.repos.d/*.repo
3433

35-
RUN yum install -y glibc.i686 glibc-devel.i686 glibc-static.i686 glibc.x86_64 glibc-devel.x86_64 glibc-static.x86_64 && \
36-
yum -y install /rpms/* && rm -rf /rpms && yum -y clean all && rm -rf /var/cache/yum/* && \
34+
RUN yum update -y && \
35+
yum install -y glibc.i686 glibc-devel.i686 glibc-static.i686 glibc.x86_64 glibc-devel.x86_64 glibc-static.x86_64 && \
36+
yum -y install /rpms/* && rm -rf /rpms && rpm --rebuilddb && yum -y clean all && rm -rf /var/cache/yum/* && \
3737
# if we updated glibc, we need to strip locales again...
3838
localedef --list-archive | grep -v -i ^en_US.utf8 | xargs localedef --delete-from-archive && \
3939
mv -f /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl && \
4040
build-locale-archive && \
41-
find /usr/share/locale -mindepth 1 -maxdepth 1 -not \( -name 'en*' -or -name 'locale.alias' \) | xargs rm -rf
41+
find /usr/share/locale -mindepth 1 -maxdepth 1 -not \( -name 'en*' -or -name 'locale.alias' \) | xargs rm -rf && \
42+
rm -rf /root/* /tmp/* /var/log/*
43+
44+
RUN ln -sf cracklib-small.pwi /usr/share/cracklib/pw_dict.pwi && \
45+
ln -sf cracklib-small.pwd /usr/share/cracklib/pw_dict.pwd && \
46+
rm -rf /var/lib/yum/history/* && \
47+
find /usr/lib64/python2.6 \( -type f -a -name '*.pyc' -o -name '*.pyo' \) -delete
48+
49+
FROM scratch
50+
LABEL maintainer="The Manylinux project"
51+
COPY --from=manylinux2010_centos-6-no-vsyscall-build / /
52+
CMD ["/bin/bash"]

docker/glibc/build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ case "${1-}" in
3131
;;
3232
all)
3333
docker_build \
34-
-t quay.io/pypa/manylinux2010_centos-6-no-vsyscall:latest \
34+
--target manylinux2010_centos-6-no-vsyscall-build \
35+
-t quay.io/pypa/manylinux2010_centos-6-no-vsyscall-build:latest \
3536
--cache-from quay.io/pypa/manylinux2010_centos-6-with-vsyscall32:latest \
3637
--cache-from quay.io/pypa/manylinux2010_centos-6-with-vsyscall64:latest \
38+
--cache-from quay.io/pypa/manylinux2010_centos-6-no-vsyscall-build:latest
39+
docker_build \
40+
-t quay.io/pypa/manylinux2010_centos-6-no-vsyscall:latest \
41+
--cache-from quay.io/pypa/manylinux2010_centos-6-no-vsyscall-build:latest \
3742
--cache-from quay.io/pypa/manylinux2010_centos-6-no-vsyscall:latest
3843
;;
3944
*)

travis-ci/tags.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@ case "${1-}" in
55
64)
66
tags=( quay.io/pypa/manylinux2010_centos-6-with-vsyscall64:latest )
77
;;
8+
combined_build)
9+
tags=(
10+
quay.io/pypa/manylinux2010_centos-6-no-vsyscall-build:latest
11+
quay.io/pypa/manylinux2010_centos-6-no-vsyscall:latest
12+
)
13+
;;
814
combined)
915
tags=( quay.io/pypa/manylinux2010_centos-6-no-vsyscall:latest )
1016
;;
1117
all)
1218
tags=(
1319
quay.io/pypa/manylinux2010_centos-6-with-vsyscall32:latest
1420
quay.io/pypa/manylinux2010_centos-6-with-vsyscall64:latest
21+
quay.io/pypa/manylinux2010_centos-6-no-vsyscall-build:latest
1522
quay.io/pypa/manylinux2010_centos-6-no-vsyscall:latest
1623
)
1724
;;
1825
*)
19-
echo "Usage: $0 {32|64|combined|all}" >&2
26+
echo "Usage: $0 {32|64|combined_build|combined|all}" >&2
2027
exit 1
2128
;;
2229
esac

0 commit comments

Comments
 (0)