From 497cb40aaff32228309ca94c98f3580208c66890 Mon Sep 17 00:00:00 2001 From: "Tuan Anh Nguyen Dang (Tadashi_Cin)" Date: Fri, 11 Oct 2024 10:30:21 +0700 Subject: [PATCH] fix: docker multiplatform (#383) * fix: multiplatform build * fix: test build --- .github/workflows/build-push-docker.yaml | 22 ++-------------------- Dockerfile | 7 ++++--- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-push-docker.yaml b/.github/workflows/build-push-docker.yaml index 4b195e148..ee151a9df 100644 --- a/.github/workflows/build-push-docker.yaml +++ b/.github/workflows/build-push-docker.yaml @@ -88,34 +88,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build docker image (amd64) + - name: Build docker image uses: docker/build-push-action@v6 with: file: Dockerfile context: . push: true - platforms: linux/amd64 + platforms: linux/amd64, linux/arm64 tags: | ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} target: ${{ matrix.target }} cache-from: type=gha cache-to: type=gha,mode=max - build-args: | - ENABLE_GRAPHRAG=true - - - name: Build docker image (arm64) - uses: docker/build-push-action@v6 - with: - file: Dockerfile - context: . - push: true - platforms: linux/arm64 - tags: | - ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - target: ${{ matrix.target }} - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - ENABLE_GRAPHRAG=false diff --git a/Dockerfile b/Dockerfile index fb6d499d5..10de1321c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,13 +15,14 @@ RUN apt-get update -qqy && \ cargo # Setup args -ARG ENABLE_GRAPHRAG=true +ARG TARGETPLATFORM +ARG TARGETARCH # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV PYTHONIOENCODING=UTF-8 -ENV ENABLE_GRAPHRAG=${ENABLE_GRAPHRAG} +ENV TARGETARCH=${TARGETARCH} # Create working directory WORKDIR /app @@ -45,7 +46,7 @@ RUN --mount=type=ssh \ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/pip \ - if [ "$ENABLE_GRAPHRAG" = "true" ]; then pip install graphrag future; fi + if [ "$TARGETARCH" = "amd64" ]; then pip install graphrag future; fi # Clean up RUN apt-get autoremove \