Skip to content

Commit

Permalink
Pass arch flag
Browse files Browse the repository at this point in the history
  • Loading branch information
LecrisUT committed Oct 9, 2024
1 parent d01e021 commit 7c5be02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/run-on-arch.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function main() {
console.log('Configuring Docker for multi-architecture support');
await exec(
path.join(__dirname, 'run-on-arch.sh'),
[ dockerFile, containerName, ...dockerRunArgs ],
[ arch, dockerFile, containerName, ...dockerRunArgs ],
{ env },
);
}
Expand Down
14 changes: 11 additions & 3 deletions src/run-on-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
set -euo pipefail

# Args
DOCKERFILE=$1
CONTAINER_NAME=$2
ARCH=$1
DOCKERFILE=$2
CONTAINER_NAME=$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)"
LOWERCASE_REPOSITORY=$(printf "%s" "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')
PACKAGE_REGISTRY="ghcr.io/${LOWERCASE_REPOSITORY}/${CONTAINER_NAME}"
DEBIAN_FRONTEND=noninteractive

# Sanitize inputs
if [[ "$ARCH" == "none" ]]; then
unset ARCH
fi

show_build_log_and_exit () {
# Show build-log.text output and exit if passed exit status != 0
status=$1
Expand Down Expand Up @@ -49,6 +55,7 @@ build_container () {
then
docker build \
"${ACTION_DIR}/Dockerfiles" \
${ARCH:+--platform=linux/$ARCH} \
--file "$DOCKERFILE" \
--tag "${CONTAINER_NAME}:latest"
else
Expand All @@ -70,6 +77,7 @@ build_container () {
docker pull "$PACKAGE_REGISTRY:latest" || true
docker build \
"${ACTION_DIR}/Dockerfiles" \
${ARCH:+--platform=linux/$ARCH} \
--file "$DOCKERFILE" \
--tag "${CONTAINER_NAME}:latest" \
--cache-from="$PACKAGE_REGISTRY" \
Expand Down

0 comments on commit 7c5be02

Please sign in to comment.