-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-docker.sh
executable file
·55 lines (45 loc) · 1.98 KB
/
build-docker.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
54
55
#!/usr/bin/env bash
# build, tag, and push docker images
# exit if a command fails
set -o errexit
# go docker image tag to use
tag="${TAG:-latest}"
# if no registry is provided, tag image as "local" registry
registry="${REGISTRY:-local}"
# set image name
image_name="pinglog"
# set image version
image_version="$(grep "ReleaseVersion" main.go | head -n1 | awk '{print $4}' | sed 's/\"//g')"
# platforms to build for
platforms="linux/amd64"
platforms+=",linux/arm"
platforms+=",linux/arm64"
platforms+=",linux/ppc64le"
# copy native image to local image repository
docker buildx build \
--build-arg TAG="${tag}" \
-t "${registry}/${image_name}:${image_version}" \
$(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:latest"; fi) \
-f docker/Dockerfile . \
--load
# push image to remote registry
docker buildx build --platform "${platforms}" \
--build-arg TAG="${tag}" \
-t "${registry}/${image_name}:${image_version}" \
$(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:latest"; fi) \
-f docker/Dockerfile . \
--push
# copy debug image to local image repository
docker buildx build \
--build-arg TAG="${tag}" \
-t "${registry}/${image_name}:${image_version}-debug" \
$(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:debug"; fi) \
-f docker/Dockerfile.debug . \
--load
# push debug image to remote registry
docker buildx build --platform "${platforms}" \
--build-arg TAG="${tag}" \
-t "${registry}/${image_name}:${image_version}-debug" \
$(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:debug"; fi) \
-f docker/Dockerfile.debug . \
--push