Skip to content

Commit 7c5be02

Browse files
committed
Pass arch flag
1 parent d01e021 commit 7c5be02

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/run-on-arch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function main() {
126126
console.log('Configuring Docker for multi-architecture support');
127127
await exec(
128128
path.join(__dirname, 'run-on-arch.sh'),
129-
[ dockerFile, containerName, ...dockerRunArgs ],
129+
[ arch, dockerFile, containerName, ...dockerRunArgs ],
130130
{ env },
131131
);
132132
}

src/run-on-arch.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
set -euo pipefail
44

55
# Args
6-
DOCKERFILE=$1
7-
CONTAINER_NAME=$2
6+
ARCH=$1
7+
DOCKERFILE=$2
8+
CONTAINER_NAME=$3
89
# Remainder of args get passed to docker
9-
declare -a DOCKER_RUN_ARGS=${@:3:${#@}}
10+
declare -a DOCKER_RUN_ARGS=${@:4:${#@}}
1011

1112
# Defaults
1213
ACTION_DIR="$(cd "$(dirname "$0")"/.. >/dev/null 2>&1 ; pwd -P)"
1314
LOWERCASE_REPOSITORY=$(printf "%s" "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')
1415
PACKAGE_REGISTRY="ghcr.io/${LOWERCASE_REPOSITORY}/${CONTAINER_NAME}"
1516
DEBIAN_FRONTEND=noninteractive
1617

18+
# Sanitize inputs
19+
if [[ "$ARCH" == "none" ]]; then
20+
unset ARCH
21+
fi
22+
1723
show_build_log_and_exit () {
1824
# Show build-log.text output and exit if passed exit status != 0
1925
status=$1
@@ -49,6 +55,7 @@ build_container () {
4955
then
5056
docker build \
5157
"${ACTION_DIR}/Dockerfiles" \
58+
${ARCH:+--platform=linux/$ARCH} \
5259
--file "$DOCKERFILE" \
5360
--tag "${CONTAINER_NAME}:latest"
5461
else
@@ -70,6 +77,7 @@ build_container () {
7077
docker pull "$PACKAGE_REGISTRY:latest" || true
7178
docker build \
7279
"${ACTION_DIR}/Dockerfiles" \
80+
${ARCH:+--platform=linux/$ARCH} \
7381
--file "$DOCKERFILE" \
7482
--tag "${CONTAINER_NAME}:latest" \
7583
--cache-from="$PACKAGE_REGISTRY" \

0 commit comments

Comments
 (0)