Docker: Improve image build scripts
This commit is contained in:
parent
f8e94ab4a5
commit
edf8763353
3 changed files with 45 additions and 25 deletions
|
@ -6,16 +6,16 @@ set -e
|
|||
export DOCKER_BUILDKIT=1
|
||||
|
||||
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
||||
echo "docker/build: image name required, version is optional" 1>&2
|
||||
echo "usage: scripts/docker/build.sh [image] [tag] [/subimage]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NUMERIC='^[0-9]+$'
|
||||
GOPROXY=${GOPROXY:-'https://proxy.golang.org,direct'}
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
|
||||
if [[ $1 ]] && [[ -z $2 ]]; then
|
||||
echo "docker/build: 'photoprism/$1:preview'...";
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
echo "docker/build: building photoprism/$1:preview...";
|
||||
docker build \
|
||||
--no-cache \
|
||||
--pull \
|
||||
|
@ -25,7 +25,7 @@ if [[ $1 ]] && [[ -z $2 ]]; then
|
|||
-t photoprism/$1:preview \
|
||||
-f docker/${1/-//}/Dockerfile .
|
||||
elif [[ $2 =~ $NUMERIC ]]; then
|
||||
echo "docker/build: 'photoprism/$1:$2'...";
|
||||
echo "docker/build: building photoprism/$1:$2,$1:latest...";
|
||||
docker build \
|
||||
--no-cache \
|
||||
--pull \
|
||||
|
@ -35,9 +35,8 @@ elif [[ $2 =~ $NUMERIC ]]; then
|
|||
-t photoprism/$1:latest \
|
||||
-t photoprism/$1:$2 \
|
||||
-f docker/${1/-//}/Dockerfile .
|
||||
else
|
||||
echo "docker/build: 'photoprism/$1:$2' from docker/${1/-//}$3/Dockerfile...";
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
elif [[ $2 == *"preview"* ]]; then
|
||||
echo "docker/build: building photoprism/$1:$2 from docker/${1/-//}$3/Dockerfile...";
|
||||
docker build $4\
|
||||
--no-cache \
|
||||
--pull \
|
||||
|
@ -46,6 +45,17 @@ else
|
|||
--build-arg GODEBUG \
|
||||
-t photoprism/$1:$2 \
|
||||
-f docker/${1/-//}$3/Dockerfile .
|
||||
else
|
||||
echo "docker/build: building photoprism/$1:$2,$1:$DOCKER_TAG-$2 from docker/${1/-//}$3/Dockerfile...";
|
||||
docker build $4\
|
||||
--no-cache \
|
||||
--pull \
|
||||
--build-arg BUILD_TAG=$DOCKER_TAG \
|
||||
--build-arg GOPROXY \
|
||||
--build-arg GODEBUG \
|
||||
-t photoprism/$1:$2 \
|
||||
-t photoprism/$1:$DOCKER_TAG-$2 \
|
||||
-f docker/${1/-//}$3/Dockerfile .
|
||||
fi
|
||||
|
||||
echo "docker/build: done"
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
export DOCKER_BUILDKIT=1
|
||||
|
||||
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
||||
echo "docker/buildx-multi: image name and architectures required (linux/amd64,linux/arm64,linux/arm)" 1>&2
|
||||
echo "usage: scripts/docker/buildx-multi.sh [image] [linux/amd64|linux/arm64|linux/arm] [tag] [/subimage]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NUMERIC='^[0-9]+$'
|
||||
GOPROXY=${GOPROXY:-'https://proxy.golang.org,direct'}
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
|
||||
# Kill old multibuilder if still alive.
|
||||
echo "docker/buildx-multi: removing existing multibuilder..."
|
||||
|
@ -22,8 +23,7 @@ sleep 5
|
|||
docker buildx create --name multibuilder --use || { echo 'failed'; exit 1; }
|
||||
|
||||
if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
|
||||
echo "docker/buildx-multi: 'photoprism/$1:preview'..."
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
echo "docker/buildx-multi: building photoprism/$1:preview..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -35,7 +35,7 @@ if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
|
|||
-t photoprism/$1:preview \
|
||||
--push .
|
||||
elif [[ $3 =~ $NUMERIC ]]; then
|
||||
echo "docker/buildx-multi: 'photoprism/$1:$3'..."
|
||||
echo "docker/buildx-multi: building photoprism/$1:$3,$1:latest..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -47,9 +47,8 @@ elif [[ $3 =~ $NUMERIC ]]; then
|
|||
-t photoprism/$1:latest \
|
||||
-t photoprism/$1:$3 \
|
||||
--push .
|
||||
elif [[ $4 ]]; then
|
||||
echo "docker/buildx-multi: 'photoprism/$1:$3' from docker/${1/-//}$4/Dockerfile..."
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
elif [[ $4 ]] && [[ $3 == *"preview"* ]]; then
|
||||
echo "docker/buildx-multi: building photoprism/$1:$3 from docker/${1/-//}$4/Dockerfile..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -60,9 +59,21 @@ elif [[ $4 ]]; then
|
|||
-f docker/${1/-//}$4/Dockerfile \
|
||||
-t photoprism/$1:$3 \
|
||||
--push .
|
||||
elif [[ $4 ]]; then
|
||||
echo "docker/buildx-multi: building photoprism/$1:$3,$1:$DOCKER_TAG-$3 from docker/${1/-//}$4/Dockerfile..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
--no-cache \
|
||||
--build-arg BUILD_TAG=$DOCKER_TAG \
|
||||
--build-arg GOPROXY \
|
||||
--build-arg GODEBUG \
|
||||
-f docker/${1/-//}$4/Dockerfile \
|
||||
-t photoprism/$1:$3 \
|
||||
-t photoprism/$1:$DOCKER_TAG-$3 \
|
||||
--push .
|
||||
else
|
||||
echo "docker/buildx-multi: 'photoprism/$1:$3' from docker/${1/-//}/Dockerfile..."
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
echo "docker/buildx-multi: building photoprism/$1:$3 from docker/${1/-//}/Dockerfile..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
export DOCKER_BUILDKIT=1
|
||||
|
||||
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
||||
echo "docker/buildx: image name and target arch required (linux/amd64,linux/arm64,linux/arm)" 1>&2
|
||||
echo "usage: scripts/docker/buildx.sh [image] linux/[amd64|arm64|arm] [tag] [/subimage]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NUMERIC='^[0-9]+$'
|
||||
GOPROXY=${GOPROXY:-'https://proxy.golang.org,direct'}
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
|
||||
if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
|
||||
echo "docker/buildx: 'photoprism/$1:preview'..."
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
echo "docker/buildx: building photoprism/$1:preview..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -25,7 +25,7 @@ if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
|
|||
-t photoprism/$1:preview \
|
||||
--push .
|
||||
elif [[ $3 =~ $NUMERIC ]]; then
|
||||
echo "docker/buildx: 'photoprism/$1:$3'..."
|
||||
echo "docker/buildx: building photoprism/$1:$3,$1:latest..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -37,9 +37,8 @@ elif [[ $3 =~ $NUMERIC ]]; then
|
|||
-t photoprism/$1:latest \
|
||||
-t photoprism/$1:$3 \
|
||||
--push .
|
||||
elif [[ $4 ]]; then
|
||||
echo "docker/buildx: 'photoprism/$1:$3' from docker/${1/-//}$4/Dockerfile..."
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
elif [[ $4 ]] && [[ $3 == *"preview"* ]]; then
|
||||
echo "docker/buildx: building photoprism/$1:$3 from docker/${1/-//}$4/Dockerfile..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -51,8 +50,7 @@ elif [[ $4 ]]; then
|
|||
-t photoprism/$1:$3 \
|
||||
--push .
|
||||
else
|
||||
echo "docker/buildx: 'photoprism/$1:$3' from docker/${1/-//}/Dockerfile..."
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
echo "docker/buildx: building photoprism/$1:$3,$1:$DOCKER_TAG-$3 from docker/${1/-//}/Dockerfile..."
|
||||
docker buildx build \
|
||||
--platform $2 \
|
||||
--pull \
|
||||
|
@ -62,6 +60,7 @@ else
|
|||
--build-arg GODEBUG \
|
||||
-f docker/${1/-//}/Dockerfile \
|
||||
-t photoprism/$1:$3 \
|
||||
-t photoprism/$1:$DOCKER_TAG-$3 \
|
||||
--push .
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue