2023-09-05 13:22:06 +00:00
|
|
|
#!/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="roulette"
|
|
|
|
|
|
|
|
# set image version
|
2023-11-05 14:32:11 +00:00
|
|
|
image_version="$(grep "ReleaseVersion" ../cmd/root.go | head -n1 | awk '{print $4}' | sed 's/\"//g')"
|
2023-09-05 13:22:06 +00:00
|
|
|
|
|
|
|
# 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}" \
|
2023-11-05 14:32:11 +00:00
|
|
|
$(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:latest"; fi) \
|
2023-09-05 13:22:06 +00:00
|
|
|
-f Dockerfile . \
|
|
|
|
--load
|
|
|
|
|
|
|
|
# push image to remote registry
|
|
|
|
docker buildx build --platform "${platforms}" \
|
|
|
|
--build-arg TAG="${tag}" \
|
|
|
|
-t "${registry}/${image_name}:${image_version}" \
|
2023-11-05 14:32:11 +00:00
|
|
|
$(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:latest"; fi) \
|
2023-09-05 13:22:06 +00:00
|
|
|
-f Dockerfile . \
|
|
|
|
--push
|