@@ -10,26 +10,53 @@ export BUILD_ROLLING="${1:-no}"
10
10
11
11
DOCKER=docker
12
12
13
+ # The following variables can be overridden using env-variables
14
+
15
+ # Set tag namespace (i.e. ghcr.io/<org> for github package registry)
16
+ TAG_NS=" ${TAG_NS:- maxking} "
17
+ # Set default platforms to build
18
+ BUILD_PLATFORM=" ${BUILD_PLATFORM:- linux/ arm64/ v8,linux/ amd64} "
19
+ # Platform to load into docker after build
20
+ # Can only load one platform, should match host
21
+ # mostly used: linux/amd64 and linux/arm64
22
+ CURRENT_PLATFORM=" ${CURRENT_PLATFORM:- linux/ amd64} "
23
+ # set env-var PUSH to yes to push to registry
24
+ PUSH=" ${PUSH:- no} "
25
+
26
+ build () {
27
+ if [ " $PUSH " = " yes" ]; then
28
+ $DOCKER buildx build --platform $BUILD_PLATFORM $@ --push
29
+ else
30
+ $DOCKER buildx build --platform $BUILD_PLATFORM $@
31
+ fi
32
+ $DOCKER buildx build --platform $CURRENT_PLATFORM $@ --load
33
+ }
34
+
35
+ # Check if the builder with name "multiarch" exists, if not create it
36
+ if ! docker buildx ls | grep -q multiarch; then
37
+ docker buildx create --name multiarch --driver docker-container --use
38
+ fi
39
+
13
40
if [ " $BUILD_ROLLING " = " yes" ]; then
14
41
echo " Building rolling releases..."
15
42
# Build the mailman-core image.
16
- $DOCKER build -f core/Dockerfile.dev \
43
+ build -f core/Dockerfile.dev \
17
44
--label version.git_commit=" $COMMIT_ID " \
18
- -t maxking /mailman-core:rolling core/
45
+ -t $TAG_NS /mailman-core:rolling core/
19
46
20
47
# Build the mailman-web image.
21
- $DOCKER build -f web/Dockerfile.dev \
48
+ build -f web/Dockerfile.dev \
22
49
--label version.git_commit=" $COMMIT_ID " \
23
- -t maxking /mailman-web:rolling web/
50
+ -t $TAG_NS /mailman-web:rolling web/
24
51
25
52
# build the postorius image.
26
- $DOCKER build -f postorius/Dockerfile.dev\
27
- --label version.git_commit=" $COMMIT_ID " \
28
- -t maxking /postorius:rolling postorius/
53
+ build -f postorius/Dockerfile.dev\
54
+ --label version.git_commit=" $COMMIT_ID " \
55
+ -t $TAG_NS /postorius:rolling postorius/
29
56
else
30
57
echo " Building stable releases..."
31
58
# Build the stable releases.
32
- $DOCKER build -t maxking /mailman-core:rolling core/
33
- $DOCKER build -t maxking /mailman-web:rolling web/
34
- $DOCKER build -t maxking /postorius:rolling postorius/
59
+ build --tag $TAG_NS /mailman-core:rolling core/
60
+ build --tag $TAG_NS /mailman-web:rolling web/
61
+ build --tag $TAG_NS /postorius:rolling postorius/
35
62
fi
0 commit comments