2021-12-10 16:18:58 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
|
|
|
|
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
2022-02-25 15:33:46 +00:00
|
|
|
echo "Usage: ${0##*/} [name] linux/[amd64|arm64|arm] [tag] [/subimage]" 1>&2
|
2021-12-10 16:18:58 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
NUMERIC='^[0-9]+$'
|
2022-03-16 18:09:53 +00:00
|
|
|
BUILD_DATE=$(/bin/date -u +%y%m%d)
|
2021-12-10 16:18:58 +00:00
|
|
|
|
2022-04-16 15:12:21 +00:00
|
|
|
echo "Starting 'photoprism/$1' build based on docker/${1/-//}$4/Dockerfile..."
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Arch: $2"
|
2022-02-17 12:45:43 +00:00
|
|
|
|
2022-02-16 13:29:42 +00:00
|
|
|
if [[ $1 ]] && [[ $2 ]] && [[ -z $3 || $3 == "preview" ]]; then
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Tags: preview"
|
2022-02-17 12:45:43 +00:00
|
|
|
|
2022-06-16 08:35:26 +00:00
|
|
|
if [[ $5 ]]; then
|
|
|
|
echo "Build Params: $5"
|
|
|
|
fi
|
|
|
|
|
2021-12-10 16:18:58 +00:00
|
|
|
docker buildx build \
|
|
|
|
--platform $2 \
|
|
|
|
--pull \
|
2021-12-12 23:23:24 +00:00
|
|
|
--no-cache \
|
2022-02-17 18:18:37 +00:00
|
|
|
--build-arg BUILD_TAG=$BUILD_DATE \
|
2022-02-16 13:29:42 +00:00
|
|
|
-f docker/${1/-//}$4/Dockerfile \
|
2022-06-16 08:35:26 +00:00
|
|
|
-t photoprism/$1:preview $5 \
|
2021-12-10 16:18:58 +00:00
|
|
|
--push .
|
|
|
|
elif [[ $3 =~ $NUMERIC ]]; then
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Tags: $3, latest"
|
2022-02-16 15:07:05 +00:00
|
|
|
|
|
|
|
if [[ $5 ]]; then
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Params: $5"
|
2022-02-16 15:07:05 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-10 16:18:58 +00:00
|
|
|
docker buildx build \
|
|
|
|
--platform $2 \
|
|
|
|
--pull \
|
2021-12-12 23:23:24 +00:00
|
|
|
--no-cache \
|
2021-12-10 16:18:58 +00:00
|
|
|
--build-arg BUILD_TAG=$3 \
|
2022-02-16 13:29:42 +00:00
|
|
|
-f docker/${1/-//}$4/Dockerfile \
|
2021-12-10 16:18:58 +00:00
|
|
|
-t photoprism/$1:latest \
|
2022-02-16 15:07:05 +00:00
|
|
|
-t photoprism/$1:$3 $5 \
|
2021-12-10 16:18:58 +00:00
|
|
|
--push .
|
2022-09-28 10:15:29 +00:00
|
|
|
elif [[ $4 ]] && [[ $3 == *"preview"* || $3 == *"unstable"* || $3 == *"test"* ]]; then
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Tags: $3"
|
2022-02-16 15:07:05 +00:00
|
|
|
|
|
|
|
if [[ $5 ]]; then
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Params: $5"
|
2022-02-16 15:07:05 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-10 16:18:58 +00:00
|
|
|
docker buildx build \
|
|
|
|
--platform $2 \
|
|
|
|
--pull \
|
2021-12-12 23:23:24 +00:00
|
|
|
--no-cache \
|
2022-02-17 18:18:37 +00:00
|
|
|
--build-arg BUILD_TAG=$BUILD_DATE \
|
2021-12-10 16:18:58 +00:00
|
|
|
-f docker/${1/-//}$4/Dockerfile \
|
2022-02-16 15:07:05 +00:00
|
|
|
-t photoprism/$1:$3 $5 \
|
2021-12-10 16:18:58 +00:00
|
|
|
--push .
|
2022-02-13 15:25:59 +00:00
|
|
|
else
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Tags: $BUILD_DATE-$3, $3"
|
2022-02-16 14:41:58 +00:00
|
|
|
|
|
|
|
if [[ $5 ]]; then
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Build Params: $5"
|
2022-02-16 14:41:58 +00:00
|
|
|
fi
|
|
|
|
|
2022-02-13 15:25:59 +00:00
|
|
|
docker buildx build \
|
|
|
|
--platform $2 \
|
|
|
|
--pull \
|
|
|
|
--no-cache \
|
2022-02-20 12:17:05 +00:00
|
|
|
--build-arg BUILD_TAG=$BUILD_DATE-$3 \
|
2022-02-16 08:51:43 +00:00
|
|
|
-f docker/${1/-//}$4/Dockerfile \
|
2022-02-13 15:25:59 +00:00
|
|
|
-t photoprism/$1:$3 \
|
2022-02-17 18:18:37 +00:00
|
|
|
-t photoprism/$1:$BUILD_DATE-$3 $5 \
|
2022-02-13 15:25:59 +00:00
|
|
|
--push .
|
2021-12-10 16:18:58 +00:00
|
|
|
fi
|
|
|
|
|
2022-02-17 18:18:37 +00:00
|
|
|
echo "Done."
|