From 309f8adbe897633c1a14e3ff4ab0c4c565057972 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Tue, 6 Jun 2023 18:08:28 +0900 Subject: [PATCH] chore(Dockerfile): update Dockerfile to support multiple architectures Signed-off-by: kahirokunn --- images/Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/images/Dockerfile b/images/Dockerfile index c1ab96d27d1..06324770d29 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 +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy as build +ARG TARGETPLATFORM +ARG BUILDPLATFORM ARG RUNNER_VERSION -ARG RUNNER_ARCH="x64" +ARG RUNNER_ARCH= 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 RUNNER_ARCH=${RUNNER_ARCH:-$(case "$TARGETPLATFORM" in "linux/arm64") echo "arm64" ;; *) echo "x64" ;; esac)} \ + && 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 \ && tar xzf ./runner.tar.gz \ && rm runner.tar.gz @@ -17,13 +20,14 @@ 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 RUNNER_ARCH=${RUNNER_ARCH:-$(case "$TARGETPLATFORM" in "linux/arm64") echo "arm64" ;; *) echo "x64" ;; esac)} \ + && export DOCKER_ARCH=x86_64 \ && 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 \ && tar zxvf docker.tgz \ && rm -rf docker.tgz -FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy ENV DEBIAN_FRONTEND=noninteractive ENV RUNNER_MANUALLY_TRAP_SIG=1