Docker: Update multi-arch development image and config #1158

Now comes with Go 1.17 pre-installed. To match production
docker-compose.yml examples, the development database was
renamed from "photoprism-db" to "mariadb".
This commit is contained in:
Michael Mayer 2021-08-31 18:08:37 +02:00
parent e5bfa6d78e
commit feb0c557c1
23 changed files with 89 additions and 72 deletions

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20210716
FROM photoprism/development:20210831
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"

View file

@ -26,9 +26,9 @@ dep: dep-tensorflow dep-js dep-go
build: generate build-js build-go
install: install-bin install-assets
test: test-js test-go
test-go: reset-test-db run-test-go
test-api: reset-test-db run-test-api
test-short: reset-test-db run-test-short
test-go: reset-test-databases run-test-go
test-api: reset-test-databases run-test-api
test-short: reset-test-databases run-test-short
acceptance-private-run-chromium: acceptance-private-restart acceptance-private acceptance-private-stop
acceptance-public-run-chromium: acceptance-restart acceptance acceptance-stop
acceptance-private-run-firefox: acceptance-private-restart acceptance-private-firefox acceptance-private-stop
@ -152,12 +152,12 @@ acceptance-private:
acceptance-private-firefox:
$(info Running JS acceptance-private tests in Firefox...)
(cd frontend && npm run acceptance-private-firefox && cd ..)
reset-photoprism-db:
$(info Purging photoprism database...)
mysql < scripts/reset-photoprism-db.sql
reset-test-db:
$(info Purging test databases...)
mysql < scripts/reset-test-db.sql
reset-mariadb:
$(info Resetting photoprism database...)
mysql < scripts/sql/reset-mariadb.sql
reset-test-databases:
$(info Resetting test databases...)
mysql < scripts/sql/init-test-databases.sql
find ./internal -type f -name '.test.*' -delete
run-test-short:
$(info Running short Go unit tests in parallel mode...)

View file

@ -8,7 +8,8 @@ services:
- seccomp:unconfined
- apparmor:unconfined
depends_on:
- photoprism-db
- mariadb
- webdav-dummy
volumes:
- "~/.cache/npm:/root/.cache/npm"
- "~/.cache/go-mod:/go/pkg/mod"
@ -28,7 +29,7 @@ services:
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_HTTP_COMPRESSION: "gzip" # Improves transfer speed and bandwidth utilization (none or gzip)
PHOTOPRISM_DATABASE_DRIVER: "mysql"
PHOTOPRISM_DATABASE_SERVER: "photoprism-db:4001"
PHOTOPRISM_DATABASE_SERVER: "mariadb:4001"
PHOTOPRISM_DATABASE_NAME: "photoprism"
PHOTOPRISM_DATABASE_USER: "root"
PHOTOPRISM_DATABASE_PASSWORD: "photoprism"
@ -137,13 +138,13 @@ services:
DRONE_TAG:
DRONE_TARGET_BRANCH:
photoprism-db:
mariadb:
image: mariadb:10.5
command: mysqld --port=4001 --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=50
expose:
- "4001"
volumes:
- "./scripts/reset-test-db.sql:/docker-entrypoint-initdb.d/reset-test-db.sql"
- "./scripts/sql/init-test-databases.sql:/docker-entrypoint-initdb.d/init-test-databases.sql"
environment:
MYSQL_ROOT_PASSWORD: photoprism
MYSQL_USER: photoprism

View file

@ -4,11 +4,12 @@ services:
photoprism:
build: .
image: photoprism/photoprism:develop
depends_on:
- postgres
- webdav-dummy
security_opt:
- seccomp:unconfined
- apparmor:unconfined
depends_on:
- postgres
ports:
- "2342:2342" # Web Server (PhotoPrism)
- "2343:2343" # Acceptance Tests
@ -64,7 +65,7 @@ services:
postgres:
image: postgres:12-alpine
ports:
- "5432:5432"
- "5432:5432" # Exposes port 5432 on host
environment:
POSTGRES_DB: photoprism
POSTGRES_USER: photoprism

View file

@ -17,11 +17,12 @@ services:
photoprism:
build: .
image: photoprism/photoprism:develop
depends_on:
- mariadb
- webdav-dummy
security_opt:
- seccomp:unconfined
- apparmor:unconfined
depends_on:
- photoprism-db
ports:
- "2342:2342" # Web Server (PhotoPrism)
- "2343:2343" # Acceptance Tests
@ -47,7 +48,7 @@ services:
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_HTTP_COMPRESSION: "gzip" # Improves transfer speed and bandwidth utilization (none or gzip)
PHOTOPRISM_DATABASE_DRIVER: "mysql"
PHOTOPRISM_DATABASE_SERVER: "photoprism-db:4001"
PHOTOPRISM_DATABASE_SERVER: "mariadb:4001"
PHOTOPRISM_DATABASE_NAME: "photoprism"
PHOTOPRISM_DATABASE_USER: "root"
PHOTOPRISM_DATABASE_PASSWORD: "photoprism"
@ -74,15 +75,16 @@ services:
PHOTOPRISM_THUMB_SIZE_UNCACHED: 7680 # On-demand rendering size limit (default 7680, min 720, max 7680)
PHOTOPRISM_JPEG_SIZE: 7680 # Size limit for converted image files in pixels (720-30000)
PHOTOPRISM_JPEG_QUALITY: 92 # Set to 95 for high-quality thumbnails (25-100)
photoprism-db:
mariadb:
image: mariadb:10.5
command: mysqld --port=4001 --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=50
expose:
- "4001"
ports:
- "4001:4001" # MySQL (for tests)
- "4001:4001" # Exposes port 4001 on host
volumes:
- "./scripts/reset-test-db.sql:/docker-entrypoint-initdb.d/reset-test-db.sql"
- "./scripts/sql/init-test-databases.sql:/docker-entrypoint-initdb.d/init-test-databases.sql"
environment:
MYSQL_ROOT_PASSWORD: photoprism
MYSQL_USER: photoprism

View file

@ -1,5 +1,5 @@
[client]
user=root
password=photoprism
host=photoprism-db
host=mariadb
port=4001

View file

@ -21,8 +21,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
COPY --chown=root:root --chmod=755 /docker/scripts/*.sh /root/.local/bin/
# Install dev / build dependencies
RUN apt-get update && apt-get -qq dist-upgrade && \
apt-get -qq install -y --no-install-recommends \
RUN apt-get update && apt dist-upgrade 2>/dev/null && apt-get -qq install -y --no-install-recommends \
build-essential \
ca-certificates \
wget \
@ -94,7 +93,6 @@ RUN /root/.local/bin/install-tensorflow.sh $TARGETARCH
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN add-apt-repository -y ppa:saiarcot895/chromium-beta && \
apt-get update && \
apt-get -qq dist-upgrade && \
apt-get -qq install chromium-browser chromium-codecs-ffmpeg-extra nodejs && \
apt-get -y autoremove && \
apt-get -y autoclean && \

View file

@ -33,6 +33,8 @@ services:
# Use photoprism/photoprism:preview instead for testing preview builds:
image: photoprism/photoprism:latest
container_name: photoprism
depends_on:
- mariadb
# Only enable automatic restarts once your installation is properly
# configured as it otherwise may get stuck in a restart loop:
# https://docs.photoprism.org/getting-started/faq/#why-is-photoprism-getting-stuck-in-a-restart-loop
@ -92,9 +94,9 @@ services:
- "./storage:/photoprism/storage"
mariadb:
restart: unless-stopped
image: arm64v8/mariadb:10.5
container_name: mariadb
restart: unless-stopped
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -110,9 +112,9 @@ services:
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# restart: unless-stopped
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours

View file

@ -45,7 +45,7 @@
"echo 'APT::Get::Assume-Yes \"true\";' > /etc/apt/apt.conf.d/80forceyes",
"echo 'APT::Get::Fix-Missing \"true\";' > /etc/apt/apt.conf.d/80fixmissing",
"apt-get -qqy update",
"apt dist-upgrade",
"apt dist-upgrade 2>/dev/null",
"apt-get -qqy install {{user `apt_packages`}}",
"apt-get -qqy autoclean",
"apt-get -qqy autoremove",

View file

@ -91,10 +91,12 @@ version: '3.5'
services:
photoprism:
restart: always
# Use photoprism/photoprism:preview instead for testing preview builds:
image: photoprism/photoprism:latest
container_name: photoprism
restart: always
depends_on:
- mariadb
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -151,9 +153,9 @@ services:
- "./backup:/var/lib/photoprism"
traefik:
restart: always
image: traefik:v2.4
container_name: traefik
restart: always
ports:
- "80:80"
- "443:443"
@ -167,9 +169,9 @@ services:
- "./certs/:/certs/"
mariadb:
restart: always
image: mariadb:10.5
container_name: mariadb
restart: always
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -183,17 +185,17 @@ services:
MYSQL_PASSWORD: "_admin_password_"
ofelia:
restart: always
image: mcuadros/ofelia:latest
container_name: ofelia
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./jobs.ini:/etc/ofelia/config.ini"
watchtower:
restart: always
image: containrrr/watchtower
container_name: watchtower
restart: always
environment:
WATCHTOWER_CLEANUP: "true"
WATCHTOWER_POLL_INTERVAL: 86400 # Checks for updates every day

View file

@ -36,7 +36,7 @@ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing
# update operating system
apt-get update
apt-get dist-upgrade
apt dist-upgrade 2>/dev/null
# install dependencies
apt-get -qq install --no-install-recommends apt-transport-https ca-certificates \

View file

@ -33,6 +33,8 @@ services:
# Use photoprism/photoprism:preview instead for testing preview builds:
image: photoprism/photoprism:latest
container_name: photoprism
depends_on:
- mariadb
# Only enable automatic restarts once your installation is properly
# configured as it otherwise may get stuck in a restart loop:
# https://docs.photoprism.org/getting-started/faq/#why-is-photoprism-getting-stuck-in-a-restart-loop
@ -86,9 +88,9 @@ services:
- "./storage:/photoprism/storage"
mariadb:
restart: unless-stopped
image: mariadb:10.5
container_name: mariadb
restart: unless-stopped
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -104,9 +106,9 @@ services:
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# restart: unless-stopped
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours

View file

@ -31,6 +31,8 @@ services:
# Use photoprism/photoprism:preview instead for testing preview builds:
image: photoprism/photoprism:latest
container_name: photoprism
depends_on:
- mariadb
# Only enable automatic restarts once your installation is properly
# configured as it otherwise may get stuck in a restart loop:
# https://docs.photoprism.org/getting-started/faq/#why-is-photoprism-getting-stuck-in-a-restart-loop
@ -76,9 +78,9 @@ services:
- "./storage:/photoprism/storage"
mariadb:
restart: unless-stopped
image: mariadb:10.5
container_name: mariadb
restart: unless-stopped
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -94,9 +96,9 @@ services:
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# restart: unless-stopped
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours

View file

@ -35,6 +35,8 @@ services:
# Use photoprism/photoprism:preview instead for testing preview builds:
image: photoprism/photoprism:latest
container_name: photoprism
depends_on:
- mariadb
# Only enable automatic restarts once your installation is properly
# configured as it otherwise may get stuck in a restart loop:
# https://docs.photoprism.org/getting-started/faq/#why-is-photoprism-getting-stuck-in-a-restart-loop
@ -88,9 +90,9 @@ services:
- "./storage:/photoprism/storage"
mariadb:
restart: unless-stopped
image: mariadb:10.5
container_name: mariadb
restart: unless-stopped
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -104,9 +106,9 @@ services:
MYSQL_PASSWORD: insecure
ofelia:
restart: unless-stopped
image: mcuadros/ofelia:latest
container_name: ofelia
restart: unless-stopped
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./jobs.ini:/etc/ofelia/config.ini"
@ -114,9 +116,9 @@ services:
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# restart: unless-stopped
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours

View file

@ -83,9 +83,9 @@ services:
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# restart: unless-stopped
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours

View file

@ -34,6 +34,8 @@ services:
# Use photoprism/photoprism:preview instead for testing preview builds:
image: photoprism/photoprism:latest
container_name: photoprism
depends_on:
- mariadb
# Only enable automatic restarts once your installation is properly
# configured as it otherwise may get stuck in a restart loop:
# https://docs.photoprism.org/getting-started/faq/#why-is-photoprism-getting-stuck-in-a-restart-loop
@ -79,9 +81,9 @@ services:
- "./storage:/photoprism/storage"
mariadb:
restart: unless-stopped
image: mariadb:10.5
container_name: mariadb
restart: unless-stopped
security_opt:
- seccomp:unconfined
- apparmor:unconfined
@ -97,9 +99,9 @@ services:
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# restart: unless-stopped
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20210716 as build
FROM photoprism/development:20210831 as build
ARG TARGETARCH
ARG TARGETPLATFORM
@ -8,10 +8,10 @@ ARG BUILD_TAG
WORKDIR "/go/src/github.com/photoprism/photoprism"
COPY . .
# Build PhotoPrism
# Build frontend and backend
RUN make dep build-js install
# Same base image as photoprism/development
# Should be the same as used for photoprism/development!
FROM ubuntu:21.04
LABEL maintainer="Michael Mayer <hello@photoprism.org>"
@ -31,8 +31,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing
# Install additional distribution packages
RUN apt-get update && apt-get -qq dist-upgrade && \
apt-get -qq install -y --no-install-recommends \
RUN apt-get update && apt dist-upgrade 2>/dev/null && apt-get -qq install -y --no-install-recommends \
gpgv \
wget \
curl \
@ -56,8 +55,7 @@ RUN apt-get update && apt-get -qq dist-upgrade && \
[ "$TARGETARCH" = "arm" ] || apt-get install darktable; \
apt-get -y autoremove && apt-get -y autoclean && apt-get clean && rm -rf /var/lib/apt/lists/*
# Set environment variables
# see https://docs.photoprism.org/getting-started/config-options/
# Set environment variables, see https://docs.photoprism.org/getting-started/config-options/
ENV TF_CPP_MIN_LOG_LEVEL="2" \
PATH="/photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
PHOTOPRISM_ASSETS_PATH="/photoprism/assets" \

View file

@ -1,23 +1,25 @@
#!/usr/bin/env bash
GOLANG_VERSION=1.16.6
set -e
GOLANG_VERSION=1.17
if [[ -z $1 ]]; then
echo "Please define architecture and version" 1>&2
echo "architecture required: amd64, arm64, or arm" 1>&2
exit 1
else
set -eux;
if [[ $1 == "amd64" ]]; then
URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-$1.tar.gz"
CHECKSUM="be333ef18b3016e9d7cb7b1ff1fdb0cac800ca0be4cf2290fe613b3d069dfe0d *go.tgz"
CHECKSUM="6bf89fc4f5ad763871cf7eac80a2d594492de7a818303283f1366a7f6a30372d *go.tgz"
elif [[ $1 == "arm64" ]]; then
URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-$1.tar.gz"
CHECKSUM="9e38047463da6daecab9017cd0599f33f84991e68263752cfab49253bbc98c30 *go.tgz"
CHECKSUM="01a9af009ada22122d3fcb9816049c1d21842524b38ef5d5a0e2ee4b26d7c3e7 *go.tgz"
elif [[ $1 == "arm" ]]; then
URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz"
CHECKSUM="b1ca342e81897da3f25da4e75ae29b267db1674fe7222d9bfc4c666bcf6fce69 *go.tgz"
CHECKSUM="ae89d33f4e4acc222bdb04331933d5ece4ae71039812f6ccd7493cb3e8ddfb4e *go.tgz"
else
echo "cpu architecture not supported by now" 1>&2
echo "unsupported architecture" 1>&2
exit 1
fi
wget -O go.tgz $URL

View file

@ -44,7 +44,7 @@ func NewTestOptions() *Options {
// Config example for MySQL / MariaDB:
// dbDriver = MySQL,
// dbDsn = "photoprism:photoprism@tcp(photoprism-db:4001)/photoprism?parseTime=true",
// dbDsn = "photoprism:photoprism@tcp(mariadb:4001)/photoprism?parseTime=true",
if dbDriver == "test" || dbDriver == "sqlite" || dbDriver == "" || dbDsn == "" {
dbDriver = SQLite

View file

@ -2,16 +2,21 @@
set -e
# see https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds
# https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds
export DOCKER_BUILDKIT=1
if [[ -z $1 ]] || [[ -z $2 ]]; then
echo "Please provide a container image name and architecture string (eg. linux/amd64,linux/arm64,linux/arm)" 1>&2
echo "Please provide the image name, and a list of target architectures e.g. linux/amd64,linux/arm64,linux/arm" 1>&2
exit 1
elif [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
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'..."
DOCKER_TAG=$(date -u +%Y%m%d)
echo "Building 'photoprism/$1:preview'...";
docker buildx create --name multibuilder --use
docker buildx build \
--platform $2 \
--no-cache \
@ -19,11 +24,8 @@ elif [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
-f docker/$1/Dockerfile \
-t photoprism/$1:preview \
--push .
docker buildx rm multibuilder
echo "Done"
else
echo "Building 'photoprism/$1:$3'...";
docker buildx create --name multibuilder --use
echo "Building 'photoprism/$1:$3'..."
docker buildx build \
--platform $2 \
--no-cache \
@ -32,6 +34,7 @@ else
-t photoprism/$1:latest \
-t photoprism/$1:$3 \
--push .
docker buildx rm multibuilder
echo "Done"
fi
docker buildx rm multibuilder
echo "Done"

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
apt-get update && apt-get -qq install -y qemu binfmt-support qemu-user-static qemu-system-arm qemu-efi-aarch64
sudo apt-get update && sudo apt-get -qq install -y qemu binfmt-support qemu-user-static qemu-system-arm qemu-efi-aarch64
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes