diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfb5dec3..f51c02c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,8 @@ jobs: distro: stretch - arch: armv7 distro: fedora_latest + - arch: aarch64 + distro: manjaro_latest - arch: armv7 distro: ubuntu18.04 - arch: aarch64 @@ -97,6 +99,9 @@ jobs: pacman -S git which --noconfirm ln -s /usr/lib/os-release /etc/os-release ;; + manjaro*) + sudo pacman -Syyu --noconfirm git which + ;; esac # Run on container @@ -184,6 +189,7 @@ jobs: ubuntu*) distro_key="ubuntu" ;; fedora*) distro_key="fedora" ;; archarm*) distro_key="archarm" ;; + manjaro*) distro_key="manjaro" ;; *) distro_key="${{ matrix.distro }}" ;; esac diff --git a/Dockerfiles/Dockerfile.aarch64.manjaro_latest b/Dockerfiles/Dockerfile.aarch64.manjaro_latest new file mode 100644 index 00000000..8c2c7df4 --- /dev/null +++ b/Dockerfiles/Dockerfile.aarch64.manjaro_latest @@ -0,0 +1,4 @@ +FROM manjarolinux/base:latest + +COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh +RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh diff --git a/Dockerfiles/Dockerfile.amd64.manjaro_latest b/Dockerfiles/Dockerfile.amd64.manjaro_latest new file mode 100644 index 00000000..8c2c7df4 --- /dev/null +++ b/Dockerfiles/Dockerfile.amd64.manjaro_latest @@ -0,0 +1,4 @@ +FROM manjarolinux/base:latest + +COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh +RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh diff --git a/README.md b/README.md index d62b7c0e..d496ea2f 100644 --- a/README.md +++ b/README.md @@ -151,9 +151,10 @@ This table details the valid `arch`/`distro` combinations: | -------- | ---------- | | armv6 | jessie, stretch, buster, bullseye, alpine_latest | | armv7 | jessie, stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest, archarm_latest | -| aarch64 | stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest, archarm_latest | +| aarch64 | stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest, archarm_latest, manjaro-latest | | s390x | jessie, stretch, buster, bullseye, ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest | | ppc64le | jessie, stretch, buster, bullseye, ubuntu16.04, ubuntu18.04,ubuntu20.04, ubuntu22.04, ubuntu_latest, ubuntu_rolling, ubuntu_devel, fedora_latest, alpine_latest | +| amd64 | manjaro-latest | Using an invalid `arch`/`distro` combination will fail. diff --git a/src/run-on-arch.js b/src/run-on-arch.js index aeca1b2e..2d304186 100644 --- a/src/run-on-arch.js +++ b/src/run-on-arch.js @@ -9,6 +9,16 @@ function slug(str) { return str.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase(); } +const archToDockerPlatform = { + "amd64": "linux/amd64", + "aarch64": "linux/arm64", + "arm64": "linux/arm64", + "armv6": "linux/arm/v6", + "armv7": "linux/arm/v7", + "ppc64le": "linux/ppc64le", + "s390x": "linux/s390x" +} + async function main() { if (process.platform !== 'linux') { throw new Error('run-on-arch supports only Linux') @@ -105,10 +115,14 @@ async function main() { arch, distro, ].join('-')); + // forcing a specific platform to be run due to + // https://github.com/moby/moby/issues/36552#issuecomment-582051871 + const dockerPlatform = archToDockerPlatform[arch] || archToDockerPlatform.amd64 + console.log('Configuring Docker for multi-architecture support') await exec( path.join(__dirname, 'run-on-arch.sh'), - [ dockerFile, containerName, ...dockerRunArgs ], + [ dockerFile, containerName, dockerPlatform, ...dockerRunArgs ], { env }, ); } diff --git a/src/run-on-arch.sh b/src/run-on-arch.sh index 813e094f..8345dcd0 100755 --- a/src/run-on-arch.sh +++ b/src/run-on-arch.sh @@ -5,8 +5,9 @@ set -euo pipefail # Args DOCKERFILE=$1 CONTAINER_NAME=$2 +DOCKER_PLATFORM=$3 # Remainder of args get passed to docker -declare -a DOCKER_RUN_ARGS=${@:3:${#@}} +declare -a DOCKER_RUN_ARGS=${@:4:${#@}} # Defaults ACTION_DIR="$(cd "$(dirname "$0")"/.. >/dev/null 2>&1 ; pwd -P)" @@ -48,6 +49,8 @@ build_container () { if [[ -z "${GITHUB_TOKEN:-}" ]] then docker build \ + --platform $DOCKER_PLATFORM \ + --pull \ "${ACTION_DIR}/Dockerfiles" \ --file "$DOCKERFILE" \ --tag "${CONTAINER_NAME}:latest" @@ -69,6 +72,8 @@ build_container () { docker pull "$PACKAGE_REGISTRY:latest" || true docker build \ + --platform $DOCKER_PLATFORM \ + --pull \ "${ACTION_DIR}/Dockerfiles" \ --file "$DOCKERFILE" \ --tag "${CONTAINER_NAME}:latest" \ @@ -96,6 +101,7 @@ run_container () { EVENT_DIR=$(dirname "$GITHUB_EVENT_PATH") docker run \ + --platform $DOCKER_PLATFORM \ --workdir "${GITHUB_WORKSPACE}" \ --rm \ -e DEBIAN_FRONTEND=noninteractive \