Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/<org> 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"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we figure out the current platform instead of hard coding it? Or, at least provide a way to override it using env var so someone can run builds on non-x86 machines too?

Also, let's rename the vars as BUILD_PLATFORM and CURRENT_PLATFORM instead? I don't think PLATFORM_TO_LAOD not matching the current platform would really work.

# 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
3 changes: 2 additions & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down