Skip to content

Commit 81cb02c

Browse files
committed
Build manylinux 2014 base image for Python workflow
1 parent 024bcdc commit 81cb02c

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed

.github/workflows/manylinux.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
on:
2+
push:
3+
pull_request:
4+
schedule:
5+
- cron: '0 0 * * 2'
6+
7+
name: Manylinux
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
env:
16+
- IMAGE_TAG: aarch64-musl
17+
TARGET: aarch64-unknown-linux-musl
18+
OPENSSL_ARCH: linux-aarch64
19+
- IMAGE_TAG: arm-musleabi
20+
TARGET: arm-unknown-linux-musleabi
21+
OPENSSL_ARCH: linux-generic32
22+
- IMAGE_TAG: arm-musleabihf
23+
TARGET: arm-unknown-linux-musleabihf
24+
OPENSSL_ARCH: linux-generic32
25+
- IMAGE_TAG: armv5te-musleabi
26+
TARGET: armv5te-unknown-linux-musleabi
27+
OPENSSL_ARCH: linux-generic32
28+
- IMAGE_TAG: armv7-musleabi
29+
TARGET: armv7-unknown-linux-musleabi
30+
OPENSSL_ARCH: linux-generic32
31+
- IMAGE_TAG: armv7-musleabihf
32+
TARGET: armv7-unknown-linux-musleabihf
33+
OPENSSL_ARCH: linux-generic32
34+
- IMAGE_TAG: i586-musl
35+
TARGET: i586-unknown-linux-musl
36+
OPENSSL_ARCH: linux-elf
37+
- IMAGE_TAG: i686-musl
38+
TARGET: i686-unknown-linux-musl
39+
OPENSSL_ARCH: linux-elf
40+
- IMAGE_TAG: mips-musl
41+
TARGET: mips-unknown-linux-musl
42+
OPENSSL_ARCH: linux-mips32
43+
# - IMAGE_TAG: mips64-muslabi64
44+
# TARGET: mips64-unknown-linux-muslabi64
45+
# OPENSSL_ARCH: linux64-mips64
46+
# - IMAGE_TAG: mips64el-muslabi64
47+
# TARGET: mips64el-unknown-linux-muslabi64
48+
# OPENSSL_ARCH: linux64-mips64
49+
- IMAGE_TAG: mipsel-musl
50+
TARGET: mipsel-unknown-linux-musl
51+
OPENSSL_ARCH: linux-mips32
52+
- IMAGE_TAG: x86_64-musl
53+
TARGET: x86_64-unknown-linux-musl
54+
OPENSSL_ARCH: linux-x86_64
55+
env: ${{ matrix.env }}
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Build Docker image
59+
run: |
60+
docker build --build-arg TARGET="$TARGET" --build-arg OPENSSL_ARCH="$OPENSSL_ARCH" -t messense/rust-musl-cross:$IMAGE_TAG-manylinux2014 -f manylinux2014.Dockerfile .
61+
docker run --rm -v "$(pwd)/tests":/home/rust/src messense/rust-musl-cross:$IMAGE_TAG-manylinux2014 cargo build
62+
- name: Push Docker image
63+
if: github.ref == 'refs/heads/master'
64+
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} && docker push messense/rust-musl-cross:$IMAGE_TAG-manylinux2014

manylinux2014.Dockerfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
FROM quay.io/pypa/manylinux2014_x86_64:latest
2+
3+
# The Rust toolchain to use when building our image
4+
ARG TOOLCHAIN=stable
5+
ARG TARGET=x86_64-unknown-linux-musl
6+
ARG OPENSSL_ARCH=linux-x86_64
7+
8+
ENV RUST_MUSL_CROSS_TARGET=$TARGET
9+
10+
# Make sure we have basic dev tools for building C libraries. Our goal
11+
# here is to support the musl-libc builds and Cargo builds needed for a
12+
# large selection of the most popular crates.
13+
#
14+
RUN yum install -y sudo
15+
16+
# Install cross-signed Let's Encrypt R3 CA certificate
17+
ADD lets-encrypt-r3-cross-signed.crt /etc/pki/ca-trust/source/anchors/
18+
RUN update-ca-trust
19+
20+
ADD config.mak /tmp/config.mak
21+
RUN cd /tmp && \
22+
curl -Lsq -o musl-cross-make.zip https://github.com/richfelker/musl-cross-make/archive/v0.9.8.zip && \
23+
unzip -q musl-cross-make.zip && \
24+
rm musl-cross-make.zip && \
25+
mv musl-cross-make-0.9.8 musl-cross-make && \
26+
cp /tmp/config.mak /tmp/musl-cross-make/config.mak && \
27+
cd /tmp/musl-cross-make && \
28+
TARGET=$TARGET make -j 4 install > /tmp/musl-cross-make.log && \
29+
ln -s /usr/local/musl/bin/$TARGET-strip /usr/local/musl/bin/musl-strip && \
30+
cd /tmp && \
31+
rm -rf /tmp/musl-cross-make /tmp/musl-cross-make.log
32+
33+
RUN mkdir -p /home/rust/libs /home/rust/src
34+
35+
# Set up our path with all our binary directories, including those for the
36+
# musl-gcc toolchain and for our Rust toolchain.
37+
ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/opt/rh/devtoolset-9/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
38+
ENV TARGET_CC=$TARGET-gcc
39+
ENV TARGET_CXX=$TARGET-g++
40+
ENV TARGET_C_INCLUDE_PATH=/usr/local/musl/$TARGET/include/
41+
42+
# Install our Rust toolchain and the `musl` target. We patch the
43+
# command-line we pass to the installer so that it won't attempt to
44+
# interact with the user or fool around with TTYs. We also set the default
45+
# `--target` to musl so that our users don't need to keep overriding it
46+
# manually.
47+
# Chmod 755 is set for root directory to allow access execute binaries in /root/.cargo/bin (azure piplines create own user).
48+
RUN chmod 755 /root/ && \
49+
curl https://sh.rustup.rs -sqSf | \
50+
sh -s -- -y --default-toolchain $TOOLCHAIN && \
51+
rustup target add $TARGET && \
52+
rm -rf /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/
53+
RUN printf "[build]\ntarget = \"$TARGET\"\n\n[target.$TARGET]\nlinker = \"$TARGET-gcc\"\n" > /root/.cargo/config && \
54+
cat /root/.cargo/config
55+
56+
# We'll build our libraries in subdirectories of /home/rust/libs. Please
57+
# clean up when you're done.
58+
WORKDIR /home/rust/libs
59+
60+
# Build a static library version of OpenSSL using musl-libc. This is
61+
# needed by the popular Rust `hyper` crate.
62+
RUN export CC=$TARGET_CC && \
63+
export C_INCLUDE_PATH=$TARGET_C_INCLUDE_PATH && \
64+
echo "Building zlib" && \
65+
VERS=1.2.11 && \
66+
CHECKSUM=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 && \
67+
cd /home/rust/libs && \
68+
curl -sqLO https://zlib.net/zlib-$VERS.tar.gz && \
69+
echo "$CHECKSUM zlib-$VERS.tar.gz" > checksums.txt && \
70+
sha256sum -c checksums.txt && \
71+
tar xzf zlib-$VERS.tar.gz && cd zlib-$VERS && \
72+
./configure --static --archs="-fPIC" --prefix=/usr/local/musl/$TARGET && \
73+
make && make install && \
74+
cd .. && rm -rf zlib-$VERS.tar.gz zlib-$VERS checksums.txt && \
75+
echo "Building OpenSSL" && \
76+
VERS=1.0.2q && \
77+
CHECKSUM=5744cfcbcec2b1b48629f7354203bc1e5e9b5466998bbccc5b5fcde3b18eb684 && \
78+
curl -sqO https://www.openssl.org/source/openssl-$VERS.tar.gz && \
79+
echo "$CHECKSUM openssl-$VERS.tar.gz" > checksums.txt && \
80+
sha256sum -c checksums.txt && \
81+
tar xzf openssl-$VERS.tar.gz && cd openssl-$VERS && \
82+
./Configure $OPENSSL_ARCH -fPIC --prefix=/usr/local/musl/$TARGET && \
83+
make depend && \
84+
make && make install && \
85+
cd .. && rm -rf openssl-$VERS.tar.gz openssl-$VERS checksums.txt
86+
87+
ENV OPENSSL_DIR=/usr/local/musl/$TARGET/ \
88+
OPENSSL_INCLUDE_DIR=/usr/local/musl/$TARGET/include/ \
89+
DEP_OPENSSL_INCLUDE=/usr/local/musl/$TARGET/include/ \
90+
OPENSSL_LIB_DIR=/usr/local/musl/$TARGET/lib/ \
91+
OPENSSL_STATIC=1
92+
93+
# Expect our source code to live in /home/rust/src
94+
WORKDIR /home/rust/src

0 commit comments

Comments
 (0)