From a61d3f37dc972d00851dfca725d842d9af6936b5 Mon Sep 17 00:00:00 2001 From: Dee Kryvenko Date: Mon, 24 Jul 2023 05:59:38 -0700 Subject: [PATCH] Enable linux/arm64 docker build and publish (#2601) * Enable linux/arm64 docker build and publish * Fix Dockerfile for multi-arch * Fix Dockerfile - missing args * Fix Dockerfile - Docker likes x86_64 * Remove unused `RUNNER_ARCH` --------- Signed-off-by: Dee Kryvenko --- .github/workflows/publish-image.yml | 3 +++ .github/workflows/release.yml | 3 +++ images/Dockerfile | 12 ++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index bf0dbfc27e8..fa906b29403 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -53,6 +53,9 @@ jobs: uses: docker/build-push-action@v3 with: context: ./images + platforms: | + linux/amd64 + linux/arm64 tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bf120014b5..de0c0472371 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -699,6 +699,9 @@ jobs: uses: docker/build-push-action@v3 with: context: ./images + platforms: | + linux/amd64 + linux/arm64 tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest diff --git a/images/Dockerfile b/images/Dockerfile index c1ab96d27d1..1ed0f4a9c3e 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -1,15 +1,18 @@ # Source: https://github.com/dotnet/dotnet-docker FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy as build +ARG TARGETOS +ARG TARGETARCH ARG RUNNER_VERSION -ARG RUNNER_ARCH="x64" ARG RUNNER_CONTAINER_HOOKS_VERSION=0.3.2 ARG DOCKER_VERSION=20.10.23 RUN apt update -y && apt install curl unzip -y WORKDIR /actions-runner -RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ +RUN export RUNNER_ARCH=${TARGETARCH} \ + && if [ "$RUNNER_ARCH" = "amd64" ]; then export RUNNER_ARCH=x64 ; fi \ + && curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-${TARGETOS}-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ && tar xzf ./runner.tar.gz \ && rm runner.tar.gz @@ -17,9 +20,10 @@ RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-c && unzip ./runner-container-hooks.zip -d ./k8s \ && rm runner-container-hooks.zip -RUN export DOCKER_ARCH=x86_64 \ +RUN export RUNNER_ARCH=${TARGETARCH} \ + && if [ "$RUNNER_ARCH" = "amd64" ]; then export DOCKER_ARCH=x86_64 ; fi \ && if [ "$RUNNER_ARCH" = "arm64" ]; then export DOCKER_ARCH=aarch64 ; fi \ - && curl -fLo docker.tgz https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz \ + && curl -fLo docker.tgz https://download.docker.com/${TARGETOS}/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz \ && tar zxvf docker.tgz \ && rm -rf docker.tgz