From 6489fa6ace77453dd15debc781b97072bec35c5a Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sun, 19 Oct 2025 20:48:17 +0200 Subject: [PATCH 1/2] Add arm64 image --- .github/workflows/build.yml | 61 +++++++++++++++++++----- docker/Dockerfile | 3 +- docker/build_scripts/build-freexl.sh | 5 ++ docker/build_scripts/build-spatialite.sh | 5 ++ 4 files changed, 60 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bb8fe1..7b87c38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,9 @@ on: - "valhalla_python" paths-ignore: - '*.md' + pull_request: + branches: + - "valhalla_python" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} @@ -20,12 +23,19 @@ concurrency: jobs: build_manylinux: - name: manylinux_2_28_x86_64 - runs-on: ubuntu-22.04 + name: manylinux_2_28_${{ matrix.platform }} + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - platform: x86_64 + runner: ubuntu-22.04 + - platform: aarch64 + runner: ubuntu-22.04-arm env: POLICY: manylinux_2_28 - PLATFORM: x86_64 + PLATFORM: ${{ matrix.platform }} COMMIT_SHA: ${{ github.sha }} steps: @@ -39,13 +49,14 @@ jobs: if: github.event_name != 'workflow_dispatch' || fromJSON(github.event.inputs.useCache) uses: actions/cache/restore@v4 with: - path: .buildx-cache-manylinux_2_28_x86_64/ - key: buildx-cache-manylinux_2_28_x86_64-${{ hashFiles('docker/**') }} - restore-keys: buildx-cache-manylinux_2_28_x86_64- + path: .buildx-cache-manylinux_2_28_${{ matrix.platform }}/ + key: buildx-cache-manylinux_2_28_${{ matrix.platform }}-${{ hashFiles('docker/**') }} + restore-keys: buildx-cache-manylinux_2_28_${{ matrix.platform }}- - name: Get branch name run: | echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV + echo "REPO_LOWERCASE=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Build image run: ./build.sh @@ -54,12 +65,38 @@ jobs: if: always() uses: actions/cache/save@v4 with: - path: .buildx-cache-manylinux_2_28_x86_64/ - key: buildx-cache-manylinux_2_28_x86_64-${{ hashFiles('docker/**') }} + path: .buildx-cache-manylinux_2_28_${{ matrix.platform }}/ + key: buildx-cache-manylinux_2_28_${{ matrix.platform }}-${{ hashFiles('docker/**') }} + + - name: Login to GitHub Container Registry + if: github.event_name == 'push' + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push image + if: github.event_name == 'push' + run: | + docker tag quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:${{ github.sha }} ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ matrix.platform }}_${{ env.BRANCH }} + docker push ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ matrix.platform }}_${{ env.BRANCH }} + docker image rm quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:${{ github.sha }} + + create_manifest: + name: Create multi-arch manifest + runs-on: ubuntu-24.04 + needs: build_manylinux + if: github.event_name == 'push' + + steps: + - name: Get branch name + run: | + echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV + echo "REPO_LOWERCASE=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Create and push manifest run: | - docker tag quay.io/pypa/manylinux_2_28_x86_64:${{ github.sha }} ghcr.io/valhalla/manylinux:2_28_${{ env.BRANCH }} - docker image rm quay.io/pypa/manylinux_2_28_x86_64:${{ github.sha }} - echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - docker push ghcr.io/valhalla/manylinux:2_28_${{ env.BRANCH }} + docker manifest create ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ env.BRANCH }} \ + --amend ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_x86_64_${{ env.BRANCH }} \ + --amend ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_aarch64_${{ env.BRANCH }} + docker manifest push ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ env.BRANCH }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 2c5caae..aed5e83 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,4 @@ -# default to latest supported policy, x86_64 -ARG BASEIMAGE=amd64/almalinux:9 +ARG BASEIMAGE=almalinux:9 ARG POLICY=manylinux_2_34 ARG PLATFORM=x86_64 ARG DEVTOOLSET_ROOTPATH=/opt/rh/gcc-toolset-14/root diff --git a/docker/build_scripts/build-freexl.sh b/docker/build_scripts/build-freexl.sh index c0f9314..18b44cf 100755 --- a/docker/build_scripts/build-freexl.sh +++ b/docker/build_scripts/build-freexl.sh @@ -18,6 +18,11 @@ check_var "${FREEXL_DOWNLOAD_URL}" fetch_source "${FREEXL_ROOT}.tar.gz" "$FREEXL_DOWNLOAD_URL" tar -xzf "${FREEXL_ROOT}.tar.gz" pushd "${FREEXL_ROOT}" +# Update config.guess and config.sub for aarch64 support +if [ -f /usr/share/automake-*/config.guess ]; then + cp -f /usr/share/automake-*/config.guess . + cp -f /usr/share/automake-*/config.sub . +fi ./configure make -j$(nproc) DESTDIR=/manylinux-rootfs make install diff --git a/docker/build_scripts/build-spatialite.sh b/docker/build_scripts/build-spatialite.sh index ad14b3a..f7c4d51 100755 --- a/docker/build_scripts/build-spatialite.sh +++ b/docker/build_scripts/build-spatialite.sh @@ -18,6 +18,11 @@ check_var "${SPATIALITE_DOWNLOAD_URL}" fetch_source "${SPATIALITE_ROOT}.tar.gz" "$SPATIALITE_DOWNLOAD_URL" tar -xzf "${SPATIALITE_ROOT}.tar.gz" pushd "${SPATIALITE_ROOT}" +# Update config.guess and config.sub for aarch64 support +if [ -f /usr/share/automake-*/config.guess ]; then + cp -f /usr/share/automake-*/config.guess . + cp -f /usr/share/automake-*/config.sub . +fi ./configure make -j$(nproc) DESTDIR=/manylinux-rootfs make install From 5edadaf5480951aca8cb23e5fa22ae0e8d8a93a7 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sun, 19 Oct 2025 20:53:25 +0200 Subject: [PATCH 2/2] Add arm64 image --- .github/workflows/build.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b87c38..0fa1692 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,13 +68,11 @@ jobs: path: .buildx-cache-manylinux_2_28_${{ matrix.platform }}/ key: buildx-cache-manylinux_2_28_${{ matrix.platform }}-${{ hashFiles('docker/**') }} - - name: Login to GitHub Container Registry - if: github.event_name == 'push' - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Push image if: github.event_name == 'push' run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + docker tag quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:${{ github.sha }} ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ matrix.platform }}_${{ env.BRANCH }} docker push ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ matrix.platform }}_${{ env.BRANCH }} docker image rm quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:${{ github.sha }} @@ -91,11 +89,10 @@ jobs: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV echo "REPO_LOWERCASE=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - - name: Login to GitHub Container Registry - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Create and push manifest run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + docker manifest create ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_${{ env.BRANCH }} \ --amend ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_x86_64_${{ env.BRANCH }} \ --amend ghcr.io/${{ env.REPO_LOWERCASE }}:2_28_aarch64_${{ env.BRANCH }}