Skip to content

Commit

Permalink
Switch to Docker --platform
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAssassin committed Dec 23, 2024
1 parent c270728 commit 01fd773
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
21 changes: 11 additions & 10 deletions ci/build-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error() {
log_message 1 "[error] $*"
}

if [[ "$ARCH" == "" ]]; then
if [[ "${ARCH:-}" == "" ]]; then
error "Usage: env ARCH=... bash $0"
exit 2
fi
Expand All @@ -29,16 +29,16 @@ this_dir="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"

case "$ARCH" in
x86_64)
docker_arch=amd64
docker_platform=linux/amd64
;;
i386)
docker_arch=i386
docker_platform=linux/386
;;
armhf)
docker_arch=arm32v7
docker_platform=linux/arm/v7
;;
aarch64)
docker_arch=arm64v8
docker_platform=linux/arm64/v8
;;
*)
echo "Unsupported \$ARCH: $ARCH"
Expand All @@ -49,7 +49,7 @@ esac
# first, we need to build the image
# we always attempt to build it, it will only be rebuilt if Docker detects changes
# optionally, we'll pull the base image beforehand
info "Building Docker image for $ARCH (Docker arch: $docker_arch)"
info "Building Docker image for $ARCH (Docker platform: $docker_platform)"

build_args=()
if [[ "${UPDATE:-}" == "" ]]; then
Expand All @@ -58,11 +58,11 @@ else
build_args+=("--pull")
fi

docker_image=linuxdeploy-plugin-qt-build:"$ARCH"
docker_image=linuxdeploy-plugin-qt-build

docker build \
--platform "$docker_platform" \
--build-arg ARCH="$ARCH" \
--build-arg docker_arch="$docker_arch" \
"${build_args[@]}" \
-t "$docker_image" \
"$this_dir"/docker
Expand Down Expand Up @@ -104,11 +104,12 @@ run_in_docker() {
# b) allow the build scripts to "mv" the binaries into the /out directory
docker run \
--rm \
--platform "$docker_platform" \
-i \
--init \
-e ARCH \
-e GITHUB_RUN_NUMBER \
-e USE_STATIC_RUNTIME \
-e ARCH \
-e CI \
--user "$uid" \
"${docker_args[@]}" \
Expand All @@ -119,7 +120,7 @@ run_in_docker() {
}

filename_suffix=
if [[ "$USE_STATIC_RUNTIME" != "" ]]; then
if [[ "${USE_STATIC_RUNTIME:-}" != "" ]]; then
filename_suffix="-static"
fi

Expand Down
8 changes: 1 addition & 7 deletions ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
# needs to be re-run in CI every time as we cannot store auto-built Docker images due to GitHub's strict quota
# it will save a lot of time in local development environments, though

ARG docker_arch

# we'll just use Debian as a base image for now, mainly because it produces less headache than Ubuntu with arm
# a big pro is that they ship an up to date CMake in their stable distribution
# also, they still provide IA-32 builds for some reason...
# some people in the AppImage community do not (want to) realize i386 is dead for good
# we are going to drop i686 in the future!
FROM ${docker_arch}/debian:stable

# variables that need to be availabe during build and runtime must(!) be repeated after FROM
ARG ARCH

FROM debian:stable

SHELL ["bash", "-x", "-c"]

Expand Down

0 comments on commit 01fd773

Please sign in to comment.