Skip to content

Commit

Permalink
feat: add manjaro images
Browse files Browse the repository at this point in the history
  • Loading branch information
boredland committed Aug 28, 2022
1 parent b818ac0 commit 7b1f25c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
distro: stretch
- arch: armv7
distro: fedora_latest
- arch: aarch64
distro: manjaro_latest
- arch: armv7
distro: ubuntu18.04
- arch: aarch64
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.manjaro_latest
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions Dockerfiles/Dockerfile.amd64.manjaro_latest
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 15 additions & 1 deletion src/run-on-arch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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 },
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/run-on-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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"
Expand All @@ -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" \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 7b1f25c

Please sign in to comment.