From 02043af878906ff55f2dcd9d6b5fb6b85cb76968 Mon Sep 17 00:00:00 2001 From: SeongTae Jeong Date: Tue, 30 Jul 2024 20:04:35 +0900 Subject: [PATCH] Add support for 'linux/arm64' platforms Related: #5765 --- .github/workflows/preview-image.yml | 20 +++++++++++++------- Dockerfile | 6 ++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/preview-image.yml b/.github/workflows/preview-image.yml index ee81a6911f..b650cf89a3 100644 --- a/.github/workflows/preview-image.yml +++ b/.github/workflows/preview-image.yml @@ -44,10 +44,10 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: 'yarn' - - name: Install Dependencies - run: | - npm install --global --force yarn@1.22.22 - yarn cache clean && yarn --frozen-lockfile --network-concurrency 1 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -58,6 +58,11 @@ jobs: username: ${{ vars.DOCKER_USER }} password: ${{ secrets.DOCKER_PASS }} + - name: Install Dependencies + run: | + npm install --global --force yarn@1.22.22 + yarn cache clean && yarn --frozen-lockfile --network-concurrency 1 + - name: Set version id: version run: | @@ -66,6 +71,7 @@ jobs: VERSION_TAG=$(jq -r .version package.json) echo "VERSION_TAG=$VERSION_TAG" >> "$GITHUB_OUTPUT" + # TODO: We can use GitHub Actions's matrix option to reduce the build time. - name: Build and push preview image to Docker Hub uses: docker/build-push-action@v4 with: @@ -76,9 +82,9 @@ jobs: context: . build-args: | test_all_deps=true - cache-from: type=gha - cache-to: type=gha,mode=max - platforms: linux/amd64 + cache-from: type=gha,scope=multi-platform + cache-to: type=gha,mode=max,scope=multi-platform + platforms: linux/amd64,linux/arm64 env: DOCKER_CONTENT_TRUST: true diff --git a/Dockerfile b/Dockerfile index 48d91528b0..830f61cd26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,9 @@ COPY --chown=redash scripts /frontend/scripts ARG code_coverage ENV BABEL_ENV=${code_coverage:+test} +# Avoid issues caused by lags in disk and network I/O speeds when working on top of QEMU emulation for multi-platform image building. +RUN yarn config set network-timeout 300000 + RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn --frozen-lockfile --network-concurrency 1; fi COPY --chown=redash client /frontend/client @@ -86,6 +89,9 @@ ENV POETRY_HOME=/etc/poetry ENV POETRY_VIRTUALENVS_CREATE=false RUN curl -sSL https://install.python-poetry.org | python3 - +# Avoid crashes, including corrupted cache artifacts, when building multi-platform images with GitHub Actions. +RUN /etc/poetry/bin/poetry cache clear pypi --all + COPY pyproject.toml poetry.lock ./ ARG POETRY_OPTIONS="--no-root --no-interaction --no-ansi"