Skip to content

Commit

Permalink
Pass arch argument
Browse files Browse the repository at this point in the history
  • Loading branch information
LecrisUT committed Oct 9, 2024
1 parent d01e021 commit 919d47a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 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 ],
[ dockerFile, containerName, arch, ...dockerRunArgs ],
{ env },
);
}
Expand Down
11 changes: 10 additions & 1 deletion src/run-on-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ set -euo pipefail
# Args
DOCKERFILE=$1
CONTAINER_NAME=$2
ARCH=${3:-amd64}
# 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
ARCH=amd64
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" \
--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" \
--platform=linux/$ARCH \
--file "$DOCKERFILE" \
--tag "${CONTAINER_NAME}:latest" \
--cache-from="$PACKAGE_REGISTRY" \
Expand Down Expand Up @@ -97,6 +105,7 @@ run_container () {
EVENT_DIR=$(dirname "$GITHUB_EVENT_PATH")

docker run \
--platform=linux/$ARCH \
--workdir "${GITHUB_WORKSPACE}" \
--rm \
-e DEBIAN_FRONTEND=noninteractive \
Expand Down

0 comments on commit 919d47a

Please sign in to comment.