From 823f8648964e08e75dbf7bad7dd088119abe75d0 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 16 Feb 2022 14:29:42 +0100 Subject: [PATCH] Docker: Reorganize image folders and update build scripts --- Makefile | 52 +++++++++++------------ docker/README.md | 4 +- docker/develop/{ => impish}/Dockerfile | 2 +- docker/photoprism/bullseye/Dockerfile | 2 +- docker/photoprism/buster/Dockerfile | 2 +- docker/photoprism/{ => impish}/Dockerfile | 6 +-- scripts/docker/build.sh | 10 ++--- scripts/docker/buildx-multi.sh | 16 +++---- scripts/docker/buildx.sh | 10 ++--- 9 files changed, 52 insertions(+), 52 deletions(-) rename docker/develop/{ => impish}/Dockerfile (99%) rename docker/photoprism/{ => impish}/Dockerfile (98%) diff --git a/Makefile b/Makefile index bdfee57e6..5e1326873 100644 --- a/Makefile +++ b/Makefile @@ -202,43 +202,43 @@ clean: rm -rf storage/backup rm -rf storage/cache rm -rf frontend/node_modules -docker-develop: docker-develop-impish docker-develop-buster docker-develop-bullseye +docker-develop: docker-develop-impish docker-develop-bullseye docker-develop-buster docker-develop-armv7 docker-develop-impish: - docker pull --platform=amd64 ubuntu:21.10 - docker pull --platform=arm64 ubuntu:21.10 - scripts/docker/buildx-multi.sh develop linux/amd64,linux/arm64 $(DOCKER_TAG) -docker-develop-buster: - docker pull --platform=amd64 golang:buster - docker pull --platform=arm64 golang:buster - scripts/docker/buildx-multi.sh develop linux/amd64,linux/arm64 buster /buster + docker pull --platform=amd64 ubuntu:impish + docker pull --platform=arm64 ubuntu:impish + scripts/docker/buildx-multi.sh develop linux/amd64,linux/arm64 $(DOCKER_TAG) /impish docker-develop-bullseye: docker pull --platform=amd64 golang:bullseye docker pull --platform=arm64 golang:bullseye scripts/docker/buildx-multi.sh develop linux/amd64,linux/arm64 bullseye /bullseye -docker-preview: docker-preview-impish docker-preview-buster docker-preview-bullseye -docker-preview-impish: - scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 -docker-preview-buster: - scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 preview-buster /buster -docker-preview-bullseye: - scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 preview-bullseye /bullseye -docker-release: docker-release-impish docker-release-buster docker-release-bullseye -docker-release-impish: - scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 $(DOCKER_TAG) -docker-release-buster: - scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 buster /buster -docker-release-bullseye: - scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 bullseye /bullseye -docker-preview-arm64: - scripts/docker/buildx.sh photoprism linux/arm64 preview-arm64 /bullseye -docker-release-arm64: - scripts/docker/buildx.sh photoprism linux/arm64 arm64 /bullseye +docker-develop-buster: + docker pull --platform=amd64 golang:buster + docker pull --platform=arm64 golang:buster + scripts/docker/buildx-multi.sh develop linux/amd64,linux/arm64 buster /buster docker-develop-armv7: docker pull --platform=arm golang:bullseye scripts/docker/buildx.sh develop linux/arm armv7 /armv7 +docker-preview: docker-preview-impish docker-preview-bullseye docker-preview-buster +docker-preview-impish: + scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 preview /impish +docker-preview-bullseye: + scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 preview-bullseye /bullseye +docker-preview-buster: + scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 preview-buster /buster +docker-preview-arm64: + scripts/docker/buildx.sh photoprism linux/arm64 preview-arm64 /bullseye docker-preview-armv7: docker pull --platform=arm photoprism/develop:armv7 scripts/docker/buildx.sh photoprism linux/arm preview-armv7 /armv7 +docker-release: docker-release-impish docker-release-bullseye docker-release-buster +docker-release-impish: + scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 $(DOCKER_TAG) /impish +docker-release-bullseye: + scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 bullseye /bullseye +docker-release-buster: + scripts/docker/buildx-multi.sh photoprism linux/amd64,linux/arm64 buster /buster +docker-release-arm64: + scripts/docker/buildx.sh photoprism linux/arm64 arm64 /bullseye docker-release-armv7: docker pull --platform=arm photoprism/develop:armv7 scripts/docker/buildx.sh photoprism linux/arm armv7 /armv7 diff --git a/docker/README.md b/docker/README.md index dd3abb712..8a8d14334 100644 --- a/docker/README.md +++ b/docker/README.md @@ -19,8 +19,8 @@ systems and devices, which saves our team a lot of time that we can then spend [ providing support and developing one of the many features that users are waiting for. Human-readable and versioned Dockerfiles as part of our public source code also help avoid "works for me" moments and -other unwelcome surprises by enabling us to have the exact same environment everywhere in [development](develop/Dockerfile) -and [production](photoprism/Dockerfile). +other unwelcome surprises by enabling us to have the exact same environment everywhere in [development](develop/impish/Dockerfile) +and [production](photoprism/impish/Dockerfile). Last but not least, virtually all file format parsers have vulnerabilities that just haven't been discovered yet. This is a known risk that can affect you even if your computer is not directly connected to the Internet. diff --git a/docker/develop/Dockerfile b/docker/develop/impish/Dockerfile similarity index 99% rename from docker/develop/Dockerfile rename to docker/develop/impish/Dockerfile index 228596827..5b53d3dff 100644 --- a/docker/develop/Dockerfile +++ b/docker/develop/impish/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:21.10 +FROM ubuntu:impish LABEL maintainer="Michael Mayer " diff --git a/docker/photoprism/bullseye/Dockerfile b/docker/photoprism/bullseye/Dockerfile index 6ca7bf7b7..b8c84c30d 100644 --- a/docker/photoprism/bullseye/Dockerfile +++ b/docker/photoprism/bullseye/Dockerfile @@ -1,5 +1,5 @@ ##################################################### BUILD STAGE ###################################################### -FROM photoprism/develop:20220215-bullseye as build +FROM photoprism/develop:20220216-bullseye as build ARG TARGETARCH ARG TARGETPLATFORM diff --git a/docker/photoprism/buster/Dockerfile b/docker/photoprism/buster/Dockerfile index 9491815a4..367d0da78 100644 --- a/docker/photoprism/buster/Dockerfile +++ b/docker/photoprism/buster/Dockerfile @@ -1,5 +1,5 @@ ##################################################### BUILD STAGE ###################################################### -FROM photoprism/develop:20220215-buster as build +FROM photoprism/develop:20220216-buster as build ARG TARGETARCH ARG TARGETPLATFORM diff --git a/docker/photoprism/Dockerfile b/docker/photoprism/impish/Dockerfile similarity index 98% rename from docker/photoprism/Dockerfile rename to docker/photoprism/impish/Dockerfile index b7d4f1885..8ad4a45df 100644 --- a/docker/photoprism/Dockerfile +++ b/docker/photoprism/impish/Dockerfile @@ -1,5 +1,5 @@ ##################################################### BUILD STAGE ###################################################### -FROM photoprism/develop:20220215 as build +FROM photoprism/develop:20220216 as build ARG TARGETARCH ARG TARGETPLATFORM @@ -9,13 +9,13 @@ ARG GODEBUG # set up project directory WORKDIR "/go/src/github.com/photoprism/photoprism" -COPY . . +COPY .. . # build frontend and backend RUN make npm dep build-js install ################################################## PRODUCTION STAGE #################################################### -FROM ubuntu:21.10 +FROM ubuntu:impish LABEL maintainer="Michael Mayer " diff --git a/scripts/docker/build.sh b/scripts/docker/build.sh index 021045467..eff198d4c 100755 --- a/scripts/docker/build.sh +++ b/scripts/docker/build.sh @@ -14,8 +14,8 @@ 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: building photoprism/$1:preview..."; +if [[ $1 ]] && [[ -z $2 || $2 == "preview" ]]; then + echo "docker/build: building photoprism/$1:preview from docker/${1/-//}$3/Dockerfile..."; docker build \ --no-cache \ --pull \ @@ -23,9 +23,9 @@ if [[ $1 ]] && [[ -z $2 ]]; then --build-arg GOPROXY \ --build-arg GODEBUG \ -t photoprism/$1:preview \ - -f docker/${1/-//}/Dockerfile . + -f docker/${1/-//}$3/Dockerfile . elif [[ $2 =~ $NUMERIC ]]; then - echo "docker/build: building photoprism/$1:$2,$1:latest..."; + echo "docker/build: building photoprism/$1:$2,$1:latest from docker/${1/-//}$3/Dockerfile..."; docker build \ --no-cache \ --pull \ @@ -34,7 +34,7 @@ elif [[ $2 =~ $NUMERIC ]]; then --build-arg GODEBUG \ -t photoprism/$1:latest \ -t photoprism/$1:$2 \ - -f docker/${1/-//}/Dockerfile . + -f docker/${1/-//}$3/Dockerfile . elif [[ $2 == *"preview"* ]]; then echo "docker/build: building photoprism/$1:$2 from docker/${1/-//}$3/Dockerfile..."; docker build $4\ diff --git a/scripts/docker/buildx-multi.sh b/scripts/docker/buildx-multi.sh index b5f96f5d9..1f8c93cad 100755 --- a/scripts/docker/buildx-multi.sh +++ b/scripts/docker/buildx-multi.sh @@ -12,18 +12,18 @@ NUMERIC='^[0-9]+$' GOPROXY=${GOPROXY:-'https://proxy.golang.org,direct'} DOCKER_TAG=$(date -u +%Y%m%d) -# Kill old multibuilder if still alive. +# kill old multi builder if still alive. echo "docker/buildx-multi: removing existing multibuilder..." docker buildx rm multibuilder 2>/dev/null -# Wait 5 seconds. +# wait 5 seconds. sleep 5 -# Create new multibuilder. +# create new multibuilder. docker buildx create --name multibuilder --use || { echo 'failed'; exit 1; } -if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then - echo "docker/buildx-multi: building photoprism/$1:preview..." +if [[ $1 ]] && [[ $2 ]] && [[ -z $3 || $3 == "preview" ]]; then + echo "docker/buildx-multi: building photoprism/$1:preview from docker/${1/-//}$4/Dockerfile..." docker buildx build \ --platform $2 \ --pull \ @@ -31,11 +31,11 @@ if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then --build-arg BUILD_TAG=$DOCKER_TAG \ --build-arg GOPROXY \ --build-arg GODEBUG \ - -f docker/${1/-//}/Dockerfile \ + -f docker/${1/-//}$4/Dockerfile \ -t photoprism/$1:preview \ --push . elif [[ $3 =~ $NUMERIC ]]; then - echo "docker/buildx-multi: building photoprism/$1:$3,$1:latest..." + echo "docker/buildx-multi: building photoprism/$1:$3,$1:latest from docker/${1/-//}$4/Dockerfile..." docker buildx build \ --platform $2 \ --pull \ @@ -43,7 +43,7 @@ elif [[ $3 =~ $NUMERIC ]]; then --build-arg BUILD_TAG=$3 \ --build-arg GOPROXY \ --build-arg GODEBUG \ - -f docker/${1/-//}/Dockerfile \ + -f docker/${1/-//}$4/Dockerfile \ -t photoprism/$1:latest \ -t photoprism/$1:$3 \ --push . diff --git a/scripts/docker/buildx.sh b/scripts/docker/buildx.sh index 8b99f2198..a742c72a7 100755 --- a/scripts/docker/buildx.sh +++ b/scripts/docker/buildx.sh @@ -12,8 +12,8 @@ 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: building photoprism/$1:preview..." +if [[ $1 ]] && [[ $2 ]] && [[ -z $3 || $3 == "preview" ]]; then + echo "docker/buildx: building photoprism/$1:preview from docker/${1/-//}$4/Dockerfile..." docker buildx build \ --platform $2 \ --pull \ @@ -21,11 +21,11 @@ if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then --build-arg BUILD_TAG=$DOCKER_TAG \ --build-arg GOPROXY \ --build-arg GODEBUG \ - -f docker/${1/-//}/Dockerfile \ + -f docker/${1/-//}$4/Dockerfile \ -t photoprism/$1:preview \ --push . elif [[ $3 =~ $NUMERIC ]]; then - echo "docker/buildx: building photoprism/$1:$3,$1:latest..." + echo "docker/buildx: building photoprism/$1:$3,$1:latest from docker/${1/-//}$4/Dockerfile..." docker buildx build \ --platform $2 \ --pull \ @@ -33,7 +33,7 @@ elif [[ $3 =~ $NUMERIC ]]; then --build-arg BUILD_TAG=$3 \ --build-arg GOPROXY \ --build-arg GODEBUG \ - -f docker/${1/-//}/Dockerfile \ + -f docker/${1/-//}$4/Dockerfile \ -t photoprism/$1:latest \ -t photoprism/$1:$3 \ --push .