-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_docker_compose.sh
executable file
·53 lines (46 loc) · 1.51 KB
/
build_docker_compose.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
shopt -s expand_aliases
if ! which docker-compose > /dev/null 2>&1; then
# Set an alias for docker-compose if it's missing
alias docker-compose='docker compose'
fi
docker --help | grep buildx
missing_buildx=$?
if [ "$missing_buildx" -eq "1" ];
then
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
docker-compose build ${BUILDARGS} $@
else
# We use docker buildx so we can build multi-platform images. Unfortunately,
# a limitation is that multi-platform images cannot be loaded from the builder
# into Docker.
docker buildx create --name super-builder --driver docker-container \
2>/dev/null || true
# Look for any images that would be built multi-platform
IS_MULTIPLATFORM=$(
docker buildx bake \
--builder super-builder \
--file docker-compose.yml \
${BUILDARGS} "$@" \
--print --progress none \
| jq 'any(.target[].platforms//[]|map(split(",";"")[])|unique; length >= 2)'
)
# If this is a single-platform build, then by default load it into Docker
echo Is this a multi-platform build? ${IS_MULTIPLATFORM}
if [ "$IS_MULTIPLATFORM" = "false" ]; then
BUILDARGS="$BUILDARGS --load"
fi
docker buildx bake \
--builder super-builder \
--file docker-compose.yml \
${BUILDARGS} "$@"
fi
ret=$?
if [ "$ret" -ne "0" ]; then
echo "Tip: if the build failed to resolve domain names,"
echo "consider running ./base/docker_nftables_setup.sh"
echo "since iptables has been disabled for docker in the"
echo "SPR installer"
exit $ret
fi