2021-06-02 07:45:40 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-08-05 18:17:59 +02:00
|
|
|
set -e
|
2021-08-05 18:06:43 +02:00
|
|
|
|
2021-08-31 18:08:37 +02:00
|
|
|
# https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds
|
2021-06-02 07:45:40 +02:00
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
|
|
|
|
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
2021-08-31 18:08:37 +02:00
|
|
|
echo "Please provide the image name, and a list of target architectures e.g. linux/amd64,linux/arm64,linux/arm" 1>&2
|
2021-06-02 07:45:40 +02:00
|
|
|
exit 1
|
2021-08-31 18:08:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Recreating multibuilder..."
|
|
|
|
docker buildx rm multibuilder 2>/dev/null || true
|
|
|
|
docker buildx create --name multibuilder --use
|
|
|
|
|
|
|
|
if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
|
|
|
|
echo "Building 'photoprism/$1:preview'..."
|
2021-06-02 07:45:40 +02:00
|
|
|
DOCKER_TAG=$(date -u +%Y%m%d)
|
|
|
|
docker buildx build \
|
|
|
|
--platform $2 \
|
|
|
|
--no-cache \
|
|
|
|
--build-arg BUILD_TAG=$DOCKER_TAG \
|
2021-06-02 11:04:31 +02:00
|
|
|
-f docker/$1/Dockerfile \
|
2021-06-02 07:45:40 +02:00
|
|
|
-t photoprism/$1:preview \
|
2021-06-02 11:04:31 +02:00
|
|
|
--push .
|
2021-06-02 07:45:40 +02:00
|
|
|
else
|
2021-08-31 18:08:37 +02:00
|
|
|
echo "Building 'photoprism/$1:$3'..."
|
2021-06-02 07:45:40 +02:00
|
|
|
docker buildx build \
|
|
|
|
--platform $2 \
|
|
|
|
--no-cache \
|
|
|
|
--build-arg BUILD_TAG=$3 \
|
2021-06-02 11:04:31 +02:00
|
|
|
-f docker/$1/Dockerfile \
|
2021-06-02 07:45:40 +02:00
|
|
|
-t photoprism/$1:latest \
|
|
|
|
-t photoprism/$1:$3 \
|
|
|
|
--push .
|
|
|
|
fi
|
2021-08-31 18:08:37 +02:00
|
|
|
|
2021-09-06 14:35:11 +02:00
|
|
|
echo "Removing multibuilder..."
|
|
|
|
docker buildx rm multibuilder 2>/dev/null || true
|
|
|
|
|
2021-08-31 18:08:37 +02:00
|
|
|
echo "Done"
|