Skip to content
Open
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
22 changes: 19 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@ jobs:
publish-docker:
name: Publish Docker Images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compatibility:
- name: manylinux
tag-suffix: ''
manylinux: manylinux2014
- name: musllinux
tag-suffix: '-musllinux'
manylinux: musllinux_1_1
environment:
name: Docker Hub
url: https://ghcr.io/pyo3/maturin
steps:
- name: Get image name from repository
id: image
run: python -c 'print("image=ghcr.io/${{ github.repository }}".lower())' >> $GITHUB_OUTPUT
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: changes
Expand All @@ -35,7 +48,9 @@ jobs:
if: ${{ steps.changes.outputs.changed == 'true' || startsWith(github.ref, 'refs/tags/') }}
id: meta
with:
images: ghcr.io/pyo3/maturin
images: ${{ steps.image.outputs.image }}
flavor: |
suffix=${{ matrix.compatibility.tag-suffix }},onlatest=true
- name: Login to GitHub Container Registry
if: ${{ steps.changes.outputs.changed == 'true' || startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
Expand All @@ -52,6 +67,7 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: MANYLINUX=${{ matrix.compatibility.manylinux }}
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache
cache-from: type=registry,ref=ghcr.io/pyo3/maturin:buildcache
cache-to: type=registry,ref=ghcr.io/pyo3/maturin:buildcache,mode=max
cache-from: type=registry,ref=${{ steps.image.outputs.image }}:buildcache${{ matrix.compatibility.tag-suffix }}
cache-to: type=registry,ref=${{ steps.image.outputs.image }}:buildcache${{ matrix.compatibility.tag-suffix }},mode=max
31 changes: 21 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ARG MANYLINUX=manylinux2014

# x86_64 base
FROM quay.io/pypa/manylinux2014_x86_64 AS base-amd64
FROM quay.io/pypa/${MANYLINUX}_x86_64 AS base-amd64
# x86_64 builder
FROM --platform=$BUILDPLATFORM ghcr.io/rust-cross/rust-musl-cross:x86_64-musl AS builder-amd64

# aarch64 base
FROM quay.io/pypa/manylinux2014_aarch64 AS base-arm64
FROM quay.io/pypa/${MANYLINUX}_aarch64 AS base-arm64
# aarch64 cross compile builder
FROM --platform=$BUILDPLATFORM ghcr.io/rust-cross/rust-musl-cross:aarch64-musl AS builder-arm64

Expand Down Expand Up @@ -43,14 +45,23 @@ ENV PATH=/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin:/opt/python/cp311
# Otherwise `cargo new` errors
ENV USER=root

RUN curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& yum install -y libffi-devel openssh-clients \
&& python3.8 -m pip install --no-cache-dir cffi \
&& python3.9 -m pip install --no-cache-dir cffi \
&& python3.10 -m pip install --no-cache-dir cffi \
&& python3.11 -m pip install --no-cache-dir cffi \
&& python3.12 -m pip install --no-cache-dir cffi \
&& mkdir /io
ARG MANYLINUX
RUN <<EOL
set -xeu
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
if [ "$MANYLINUX" = 'manylinux2014' ]
then
yum install -y libffi-devel openssh-clients
else
apk add --no-cache libffi-dev
fi
python3.8 -m pip install --no-cache-dir cffi
python3.9 -m pip install --no-cache-dir cffi
python3.10 -m pip install --no-cache-dir cffi
python3.11 -m pip install --no-cache-dir cffi
python3.12 -m pip install --no-cache-dir cffi
mkdir /io
EOL

COPY --from=builder /usr/bin/maturin /usr/bin/maturin

Expand Down
Loading