-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
docker_buildx
32 lines (28 loc) · 1.11 KB
/
docker_buildx
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
#!/bin/bash -e
# Build for amd64 and arm64
PLATFORMS="linux/amd64,linux/arm64"
EXTRA_BUILDX_ARGS=$@
CACHE_LOCATION="/tmp/docker-cache"
if [[ "${EXTRA_BUILDX_ARGS}" == *"--load"* ]]; then
# We have to load the image for the current architecture only in order to run tests, so let's
# pull FROM the multi-arch build that happened previously
PLATFORMS="linux/${TRAVIS_CPU_ARCH}"
CACHE="--cache-from=type=local,src=${CACHE_LOCATION}"
elif [[ "${EXTRA_BUILDX_ARGS}" == *"--push"* ]]; then
# Push ALL architectures FROM the multi-arch build cache that happened previously
CACHE="--cache-from=type=local,src=${CACHE_LOCATION}"
else
# This is the multi-arch build that we should cache and use later
CACHE="--cache-to=type=local,dest=${CACHE_LOCATION}"
fi
docker buildx build \
$CACHE \
--platform "${PLATFORMS}" \
--progress=plain \
--build-arg kafka_version=$KAFKA_VERSION \
--build-arg scala_version=$TRAVIS_SCALA_VERSION \
--build-arg vcs_ref=$TRAVIS_COMMIT \
--build-arg build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t wurstmeister/kafka \
$EXTRA_BUILDX_ARGS \
.