Skip to content

Commit 6e29de2

Browse files
committed
ci: Supply platform argument to docker commands.
Later versions of docker require a `--platform` argument when building and running from a platform-specific image that differs from the host platform.
1 parent 89720b7 commit 6e29de2

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

ci/test/00_setup_env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-cert
6868
export GOAL=${GOAL:-install}
6969
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
7070
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}
71+
72+
# The --platform argument used with `docker build` and `docker run`.
73+
export CI_IMAGE_PLATFORM=${CI_IMAGE_PLATFORM:-"linux"} # Force linux, but use native arch by default

ci/test/00_setup_env_arm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export HOST=arm-linux-gnueabihf
1010
export DPKG_ADD_ARCH="armhf"
1111
export PACKAGES="python3-zmq g++-arm-linux-gnueabihf busybox libc6:armhf libstdc++6:armhf libfontconfig1:armhf libxcb1:armhf"
1212
export CONTAINER_NAME=ci_arm_linux
13-
export CI_IMAGE_NAME_TAG="docker.io/arm64v8/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-arm-linux-gnueabihf (version 12.2, similar to guix) can cross-compile
13+
export CI_IMAGE_NAME_TAG="docker.io/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-arm-linux-gnueabihf (version 12.2, similar to guix) can cross-compile
14+
export CI_IMAGE_PLATFORM="linux/arm64"
1415
export USE_BUSY_BOX=true
1516
export RUN_UNIT_TESTS=true
1617
export RUN_FUNCTIONAL_TESTS=false

ci/test/00_setup_env_i686_multiprocess.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export LC_ALL=C.UTF-8
88

99
export HOST=i686-pc-linux-gnu
1010
export CONTAINER_NAME=ci_i686_multiprocess
11-
export CI_IMAGE_NAME_TAG="docker.io/amd64/ubuntu:24.04"
11+
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:24.04"
12+
export CI_IMAGE_PLATFORM="linux/amd64"
1213
export PACKAGES="llvm clang g++-multilib"
1314
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
1415
export GOAL="install"

ci/test/00_setup_env_s390x.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export LC_ALL=C.UTF-8
99
export HOST=s390x-linux-gnu
1010
export PACKAGES="python3-zmq"
1111
export CONTAINER_NAME=ci_s390x
12-
export CI_IMAGE_NAME_TAG="docker.io/s390x/ubuntu:24.04"
12+
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:24.04"
13+
export CI_IMAGE_PLATFORM="linux/s390x"
1314
export TEST_RUNNER_EXTRA="--exclude rpc_bind,feature_bind_extra" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
1415
export RUN_FUNCTIONAL_TESTS=true
1516
export GOAL="install"

ci/test/00_setup_env_win64.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_win64
10-
export CI_IMAGE_NAME_TAG="docker.io/amd64/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-mingw-w64-x86-64-posix (version 12.2, similar to guix) can cross-compile
10+
export CI_IMAGE_NAME_TAG="docker.io/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-mingw-w64-x86-64-posix (version 12.2, similar to guix) can cross-compile
11+
export CI_IMAGE_PLATFORM="linux/amd64"
1112
export HOST=x86_64-w64-mingw32
1213
export DPKG_ADD_ARCH="i386"
1314
export PACKAGES="nsis g++-mingw-w64-x86-64-posix wine-binfmt wine64 wine32 file"

ci/test/02_run_container.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
1414
# Though, exclude those with newlines to avoid parsing problems.
1515
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
1616
# System-dependent env vars must be kept as is. So read them from the container.
17-
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
17+
docker run --platform="${CI_IMAGE_PLATFORM}" --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
1818

1919
# Env vars during the build can not be changed. For example, a modified
2020
# $MAKEJOBS is ignored in the build process. Use --cpuset-cpus as an
@@ -31,6 +31,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
3131
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
3232
--build-arg "FILE_ENV=${FILE_ENV}" \
3333
$MAYBE_CPUSET \
34+
--platform="${CI_IMAGE_PLATFORM}" \
3435
--label="${CI_IMAGE_LABEL}" \
3536
--tag="${CONTAINER_NAME}" \
3637
"${BASE_READ_ONLY_DIR}"
@@ -100,6 +101,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
100101
--env-file /tmp/env-$USER-$CONTAINER_NAME \
101102
--name "$CONTAINER_NAME" \
102103
--network ci-ip6net \
104+
--platform="${CI_IMAGE_PLATFORM}" \
103105
"$CONTAINER_NAME")
104106
export CI_CONTAINER_ID
105107
export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}"

0 commit comments

Comments
 (0)