From 22f7816aea7b04325f5f9ef65690b0f41fbe4bd6 Mon Sep 17 00:00:00 2001 From: jonded94 Date: Thu, 7 Mar 2024 15:45:09 +0100 Subject: [PATCH] Implement docker arm build (necessary for Pull Request #34) (#37) Enable CI docker builds; switch to manylinux 2_28; enable ARM Docker build --- .github/workflows/build-docker.yml | 68 ++++++++++++++++++++++++++++++ Dockerfile | 19 +++++++-- 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-docker.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 00000000..5806520c --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,68 @@ +name: Build manylinux docker container + +on: + push: + tags: + - '*' + branches: + - develop + - ci/* + paths: + - Dockerfile + + pull_request: + types: + - opened + - synchronize + branches: + - develop + paths: + - Dockerfile + +env: + REGISTRY: ghcr.io + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: + - name: Prepare + run: | + if [ "${{ matrix.platform }}" = "linux/amd64" ]; then + echo "TARGET_ARCH=x86_64" >> $GITHUB_ENV + elif [ "${{ matrix.platform }}" = "linux/arm64" ]; then + echo "TARGET_ARCH=aarch64" >> $GITHUB_ENV + fi + - name: Checkout + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build + id: docker_build + uses: docker/build-push-action@v5 + with: + context: ./ + file: ./Dockerfile + push: ${{ github.ref == 'refs/heads/develop' }} + platforms: ${{ matrix.platform }} + tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/resiliparse-manylinux_2_28_${{ env.TARGET_ARCH }}:latest + build-args: | + TARGET_ARCH=${{ env.TARGET_ARCH }} diff --git a/Dockerfile b/Dockerfile index d0f1c26a..9d0555e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,25 @@ -FROM quay.io/pypa/manylinux2014_x86_64:latest +ARG TARGET_ARCH +FROM quay.io/pypa/manylinux_2_28_${TARGET_ARCH}:latest RUN set -x \ && yum install -y \ - devtoolset-10-libasan-devel \ + gcc-toolset-10-libasan-devel \ lz4-devel \ - uchardet-devel \ zlib-devel +RUN set -x \ + && curl -Lf https://gitlab.freedesktop.org/uchardet/uchardet/-/archive/v0.0.8/uchardet-v0.0.8.tar.gz > uchardet.tar.gz \ + && tar -xf uchardet.tar.gz \ + && (cd uchardet-* && mkdir build \ + && cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_CXX_STANDARD=17 \ + -DLEXBOR_BUILD_STATIC=ON \ + -B build \ + && cmake --build build -j$(nproc) --target install) \ + && rm -rf uchardet* + RUN set -x \ && curl -Lf https://github.com/lexbor/lexbor/archive/refs/tags/v2.2.0.tar.gz > lexbor.tar.gz \ && tar -xf lexbor.tar.gz \