Skip to content

[manylinux2014] Use a single Dockerfile for all images #876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ env:
jobs:
include:
- arch: amd64
env: PLATFORM="x86_64"
env: POLICY="manylinux2014" PLATFORM="x86_64"
- arch: amd64
env: PLATFORM="i686"
env: POLICY="manylinux2014" PLATFORM="i686"
- arch: arm64-graviton2
virt: vm
group: edge
env: PLATFORM="aarch64"
env: POLICY="manylinux2014" PLATFORM="aarch64"
- arch: ppc64le
env: PLATFORM="ppc64le"
env: POLICY="manylinux2014" PLATFORM="ppc64le"
- arch: s390x
env: PLATFORM="s390x"
env: POLICY="manylinux2014" PLATFORM="s390x"

script:
- PLATFORM=$PLATFORM TRAVIS_COMMIT=$TRAVIS_COMMIT ./build.sh
# The following scripts uses POLICY, PLATFORM and TRAVIS_COMMIT environment variables
- ./build.sh

deploy:
provider: script
script: docker/deploy.sh
# The following scripts uses POLICY, PLATFORM and TRAVIS_COMMIT environment variables
script: ./deploy.sh
on:
branch: manylinux2014
repo: pypa/manylinux
50 changes: 48 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,53 @@
#!/bin/bash

# Stop at any error, show all commands
set -ex
set -exuo pipefail

# Export variable needed by 'docker build --build-arg'
export POLICY
export PLATFORM

docker build --rm -t quay.io/pypa/manylinux2014_$PLATFORM:$TRAVIS_COMMIT -f docker/Dockerfile-$PLATFORM docker/
# get docker default multiarch image prefix for PLATFORM
if [ "${PLATFORM}" == "x86_64" ]; then
MULTIARCH_PREFIX="amd64/"
elif [ "${PLATFORM}" == "i686" ]; then
MULTIARCH_PREFIX="i386/"
elif [ "${PLATFORM}" == "aarch64" ]; then
MULTIARCH_PREFIX="arm64v8/"
elif [ "${PLATFORM}" == "ppc64le" ]; then
MULTIARCH_PREFIX="ppc64le/"
elif [ "${PLATFORM}" == "s390x" ]; then
MULTIARCH_PREFIX="s390x/"
else
echo "Unsupported platform: '${PLATFORM}'"
exit 1
fi

# setup BASEIMAGE and its specific properties
if [ "${POLICY}" == "manylinux2014" ]; then
if [ "${PLATFORM}" == "s390x" ]; then
BASEIMAGE="s390x/clefos:7"
else
BASEIMAGE="${MULTIARCH_PREFIX}centos:7"
fi
DEVTOOLSET_ROOTPATH="/opt/rh/devtoolset-9/root"
PREPEND_PATH="${DEVTOOLSET_ROOTPATH}/usr/bin:"
if [ "${PLATFORM}" == "i686" ]; then
LD_LIBRARY_PATH_ARG="${DEVTOOLSET_ROOTPATH}/usr/lib:${DEVTOOLSET_ROOTPATH}/usr/lib/dyninst:/usr/local/lib"
else
LD_LIBRARY_PATH_ARG="${DEVTOOLSET_ROOTPATH}/usr/lib64:${DEVTOOLSET_ROOTPATH}/usr/lib:${DEVTOOLSET_ROOTPATH}/usr/lib64/dyninst:${DEVTOOLSET_ROOTPATH}/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
fi
else
echo "Unsupported policy: '${POLICY}'"
exit 1
fi
export BASEIMAGE
export DEVTOOLSET_ROOTPATH
export PREPEND_PATH
export LD_LIBRARY_PATH_ARG

docker build \
--build-arg POLICY --build-arg PLATFORM --build-arg BASEIMAGE \
--build-arg DEVTOOLSET_ROOTPATH --build-arg PREPEND_PATH --build-arg LD_LIBRARY_PATH_ARG \
--rm -t quay.io/pypa/${POLICY}_${PLATFORM}:${TRAVIS_COMMIT} \
-f docker/Dockerfile docker/
2 changes: 1 addition & 1 deletion docker/deploy.sh → deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
tag="quay.io/pypa/manylinux2014_$PLATFORM"
tag="quay.io/pypa/${POLICY}_${PLATFORM}"
build_id=$(git show -s --format=%cd-%h --date=short $TRAVIS_COMMIT)

docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
Expand Down
35 changes: 35 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# default to latest supported policy, x86_64
ARG BASEIMAGE=amd64/centos:7
ARG POLICY=manylinux2014
ARG PLATFORM=x86_64
ARG DEVTOOLSET_ROOTPATH=
ARG LD_LIBRARY_PATH_ARG=
ARG PREPEND_PATH=

FROM $BASEIMAGE
ARG POLICY
ARG PLATFORM
ARG DEVTOOLSET_ROOTPATH
ARG LD_LIBRARY_PATH_ARG
ARG PREPEND_PATH
LABEL maintainer="The ManyLinux project"

ENV AUDITWHEEL_POLICY=${POLICY} AUDITWHEEL_ARCH=${PLATFORM} AUDITWHEEL_PLAT=${POLICY}_${PLATFORM}
ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8
ENV DEVTOOLSET_ROOTPATH=${DEVTOOLSET_ROOTPATH}
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH_ARG}
ENV PATH=${PREPEND_PATH}${PATH}
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

# setup entrypoint, this will wrap commands with `linux32` with i686 images
COPY build_scripts/install-entrypoint.sh /build_scripts/install-entrypoint.sh
RUN bash /build_scripts/install-entrypoint.sh && rm -rf build_scripts
COPY manylinux-entrypoint /usr/local/bin/manylinux-entrypoint
ENTRYPOINT ["manylinux-entrypoint"]

COPY build_scripts /build_scripts
RUN manylinux-entrypoint bash build_scripts/build.sh && rm -rf build_scripts

ENV SSL_CERT_FILE=/opt/_internal/certs.pem

CMD ["/bin/bash"]
19 changes: 0 additions & 19 deletions docker/Dockerfile-aarch64

This file was deleted.

27 changes: 0 additions & 27 deletions docker/Dockerfile-i686

This file was deleted.

19 changes: 0 additions & 19 deletions docker/Dockerfile-ppc64le

This file was deleted.

19 changes: 0 additions & 19 deletions docker/Dockerfile-s390x

This file was deleted.

19 changes: 0 additions & 19 deletions docker/Dockerfile-x86_64

This file was deleted.

14 changes: 14 additions & 0 deletions docker/build_scripts/install-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Install entrypoint:
# make sure yum is configured correctly and linux32 is available on i686

# Stop at any error, show all commands
set -exuo pipefail

if [ "${AUDITWHEEL_PLAT}" == "manylinux2014_i686" ]; then
echo "i386" > /etc/yum/vars/basearch
yum -y update
yum install -y util-linux-ng
yum clean all
rm -rf /var/cache/yum
fi
9 changes: 9 additions & 0 deletions docker/manylinux-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -eu

if [ "${AUDITWHEEL_ARCH}" == "i686" ]; then
linux32 "$@"
else
exec "$@"
fi