-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
31 lines (26 loc) · 1.05 KB
/
build.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
#!/bin/sh
# This script demonstrates how to use `docker buildx` to build container
# images for the linux/amd64 and linux/arm64 platforms. It creates a
# `docker buildx` builder instance when required.
#
# If you change the platforms, be sure to
#
# (1) delete the buildx builder named `skaffold-builder`, and
# (2) update the corresponding node-affinities in k8s/pod.yaml.
PUSH_IMAGE="true"
# The platforms to build.
platforms="linux/amd64,linux/arm64"
# `buildx` uses named _builder_ instances configured for specific platforms.
# This script creates a `skaffold-builder` as required.
if ! docker buildx inspect skaffold-builder >/dev/null 2>&1; then
docker buildx create --name skaffold-builder --platform $platforms
fi
# Building for multiple platforms requires pushing to a registry
# as the Docker Daemon cannot load multi-platform images.
if [ "$PUSH_IMAGE" = true ]; then
args="--platform $platforms --push"
else
args="--load"
fi
set -x # show the command-line
docker buildx build --builder skaffold-builder --tag $IMAGE $args "$BUILD_CONTEXT"