From 956cce026e81e79398ce02c5dd93a5ad4fa3cc1a Mon Sep 17 00:00:00 2001 From: Min Idzelis Date: Thu, 30 Jan 2025 14:33:05 +0000 Subject: [PATCH] Adapt build script to aarch64 platform --- build.sh | 46 ++++++++++++++++++++++++++++++++++++---------- web/Dockerfile | 3 ++- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 9d8fe7a2..e88007c8 100755 --- a/build.sh +++ b/build.sh @@ -10,26 +10,52 @@ export BUILD_ROLLING="${1:-no}" DOCKER=docker +# The following variables can be overridden using env-variables + +# Set tag namespace (i.e. ghcr.io/ for github package registry) +TAG_NS="${TAG_NS:-maxking}" +# Set default platforms to build +PLATFORM="${PLATFORM:-linux/arm64/v8,linux/amd64}" +# Platform to load into docker after build +# Can only load one platform, should match host +PLATFORM_TO_LOAD="linux/amd64" +# set env-var PUSH to yes to push to registry +PUSH="${PUSH:-no}" + +build() { + if [ "$PUSH" = "yes" ]; then + $DOCKER buildx build --platform $PLATFORM $@ --push + else + $DOCKER buildx build --platform $PLATFORM $@ + fi + $DOCKER buildx build --platform $PLATFORM_TO_LOAD $@ --load +} + +# Check if the builder with name "multiarch" exists, if not create it +if ! docker buildx ls | grep -q multiarch; then + docker buildx create --name multiarch --driver docker-container --use +fi + if [ "$BUILD_ROLLING" = "yes" ]; then echo "Building rolling releases..." # Build the mailman-core image. - $DOCKER build -f core/Dockerfile.dev \ + build -f core/Dockerfile.dev \ --label version.git_commit="$COMMIT_ID" \ - -t maxking/mailman-core:rolling core/ + -t $TAG_NS/mailman-core:rolling core/ # Build the mailman-web image. - $DOCKER build -f web/Dockerfile.dev \ + build -f web/Dockerfile.dev \ --label version.git_commit="$COMMIT_ID" \ - -t maxking/mailman-web:rolling web/ + -t $TAG_NS/mailman-web:rolling web/ # build the postorius image. - $DOCKER build -f postorius/Dockerfile.dev\ - --label version.git_commit="$COMMIT_ID"\ - -t maxking/postorius:rolling postorius/ + build -f postorius/Dockerfile.dev\ + --label version.git_commit="$COMMIT_ID"\ + -t $TAG_NS/postorius:rolling postorius/ else echo "Building stable releases..." # Build the stable releases. - $DOCKER build -t maxking/mailman-core:rolling core/ - $DOCKER build -t maxking/mailman-web:rolling web/ - $DOCKER build -t maxking/postorius:rolling postorius/ + build --tag $TAG_NS/mailman-core:rolling core/ + build --tag $TAG_NS/mailman-web:rolling web/ + build --tag $TAG_NS/postorius:rolling postorius/ fi diff --git a/web/Dockerfile b/web/Dockerfile index e4201624..ab15985b 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -17,7 +17,8 @@ RUN --mount=type=cache,target=/root/.cache \ && python3 -m pip install --break-system-packages -U 'Django<4.3' pip setuptools wheel \ && pip install --break-system-packages -r /tmp/requirements.txt \ whoosh \ - uwsgi \ + # later builds of uwsgi don't compile on aarch64 + uwsgi==2.0.25 \ psycopg2 \ dj-database-url \ mysqlclient \