Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dockerfiles: Upgrade Ubuntu base image & Go version
Reduces the number of layers by combining commands and env variables.
  • Loading branch information
lastzero committed May 15, 2021
1 parent 7637cb8 commit 77ddcec
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 239 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,4 +1,4 @@
FROM photoprism/development:20210422
FROM photoprism/development:20210515

# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -165,7 +165,7 @@ clean:
rm -rf storage/cache
rm -rf frontend/node_modules
docker-development:
docker pull ubuntu:20.10
docker pull ubuntu:21.04
scripts/docker-build.sh development $(DOCKER_TAG)
scripts/docker-push.sh development $(DOCKER_TAG)
docker-photoprism:
Expand All @@ -179,14 +179,14 @@ docker-photoprism-local:
docker-photoprism-pull:
docker pull photoprism/photoprism:latest
docker-photoprism-arm64-preview:
docker pull ubuntu:20.10
docker pull ubuntu:21.04
scripts/docker-build.sh photoprism-arm64
scripts/docker-push.sh photoprism-arm64
docker-photoprism-arm64:
scripts/docker-build.sh photoprism-arm64 $(DOCKER_TAG)
scripts/docker-push.sh photoprism-arm64 $(DOCKER_TAG)
docker-photoprism-arm32-preview:
docker pull ubuntu:20.10
docker pull ubuntu:21.04
scripts/docker-build.sh photoprism-arm32
scripts/docker-push.sh photoprism-arm32
docker-photoprism-arm32:
Expand Down
36 changes: 17 additions & 19 deletions docker/demo/Dockerfile
@@ -1,31 +1,29 @@
FROM photoprism/photoprism:preview as build

# Hide TensorFlow warnings
ENV TF_CPP_MIN_LOG_LEVEL 2
# Set environment variables
ENV TF_CPP_MIN_LOG_LEVEL=2 \
PHOTOPRISM_STORAGE_PATH="/photoprism/storage" \
PHOTOPRISM_DEBUG="false" \
PHOTOPRISM_READONLY="false" \
PHOTOPRISM_PUBLIC="true" \
HOTOPRISM_DEMO="true" \
PHOTOPRISM_EXPERIMENTAL="true" \
PHOTOPRISM_UPLOAD_NSFW="false" \
PHOTOPRISM_DETECT_NSFW="false" \
PHOTOPRISM_THUMB_FILTER="lanczos" \
PHOTOPRISM_THUMB_UNCACHED="true" \
PHOTOPRISM_THUMB_SIZE=4096 \
PHOTOPRISM_THUMB_SIZE_UNCACHED=4096 \
PHOTOPRISM_JPEG_SIZE=4096 \
PHOTOPRISM_JPEG_QUALITY=95 \
PHOTOPRISM_SITE_CAPTION="Demo"

# Copy assets
COPY /docker/demo/index.tmpl /photoprism/assets/templates

# Download example photos
RUN wget -qO- https://dl.photoprism.org/qa/demo.tar.gz | tar xvz -C /photoprism/originals

# Configure PhotoPrism
ENV PHOTOPRISM_STORAGE_PATH /photoprism/storage
ENV PHOTOPRISM_DEBUG false
ENV PHOTOPRISM_READONLY false
ENV PHOTOPRISM_PUBLIC true
ENV PHOTOPRISM_DEMO true
ENV PHOTOPRISM_EXPERIMENTAL true
ENV PHOTOPRISM_UPLOAD_NSFW false
ENV PHOTOPRISM_DETECT_NSFW false
ENV PHOTOPRISM_THUMB_FILTER lanczos
ENV PHOTOPRISM_THUMB_UNCACHED true
ENV PHOTOPRISM_THUMB_SIZE 4096
ENV PHOTOPRISM_THUMB_SIZE_UNCACHED 4096
ENV PHOTOPRISM_JPEG_SIZE 4096
ENV PHOTOPRISM_JPEG_QUALITY 95
ENV PHOTOPRISM_SITE_CAPTION "Demo"

# Import example photos
RUN photoprism restore -a
RUN photoprism index
Expand Down
45 changes: 20 additions & 25 deletions docker/development/Dockerfile
@@ -1,10 +1,20 @@
FROM ubuntu:20.10
FROM ubuntu:21.04

LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"

ARG BUILD_TAG

ENV DEBIAN_FRONTEND noninteractive
# Set environment variables
ENV DEBIAN_FRONTEND="noninteractive" \
LD_LIBRARY_PATH="/root/.local/lib:/usr/local/lib:/usr/lib:/lib" \
TF_CPP_MIN_LOG_LEVEL="0" \
NODE_ENV="production" \
GOPATH="/go" \
GOBIN="/go/bin" \
PATH="/go/bin:/usr/local/go/bin:~/.local/bin:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
TMPDIR="/tmp" \
GO111MODULE="on" \
CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

# Configure apt
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
Expand Down Expand Up @@ -70,12 +80,10 @@ RUN apt-get update && apt-get upgrade && \
# We also have custom builds available:
# https://dl.photoprism.org/tensorflow/linux/
#
ENV LD_LIBRARY_PATH /root/.local/lib:/usr/local/lib:/usr/lib:/lib
ENV TF_CPP_MIN_LOG_LEVEL 0
RUN curl -L \
"https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-cpu-1.15.2.tar.gz" | \
tar -C "/usr" -xz
RUN ldconfig
tar -C "/usr" -xz && \
ldconfig

# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
Expand All @@ -85,36 +93,23 @@ RUN add-apt-repository -y ppa:saiarcot895/chromium-beta && \
apt-get install chromium-browser chromium-codecs-ffmpeg-extra nodejs && \
apt-get autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \
umask 0000

# Set default https://en.wikipedia.org/wiki/Umask
RUN umask 0000

# Install and configure NodeJS Package Manager (npm)
ENV NODE_ENV production
# Install NodeJS & NPM
RUN npm install --unsafe-perm=true --allow-root -g npm testcafe chromedriver && \
npm config set cache ~/.cache/npm

# Install Go
ENV GOLANG_VERSION 1.16.3
ENV GOLANG_VERSION 1.16.4
RUN set -eux; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
wget -O go.tgz "$url"; \
echo "951a3c7c6ce4e56ad883f97d9db74d3d6d80d5fec77455c6ada6c1f7ac4776d2 *go.tgz" | sha256sum -c -; \
echo "7154e88f5a8047aad4b80ebace58a059e36e7e2e4eb3b383127a28c711b4ff59 *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
export PATH="/usr/local/go/bin:$PATH"; \
go version

# Configure Go environment
ENV GOPATH /go
ENV GOBIN $GOPATH/bin
ENV PATH $GOBIN:/usr/local/go/bin:~/.local/bin:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV TMPDIR /tmp
ENV GO111MODULE on
ENV CGO_CFLAGS "-g -O2 -Wno-return-local-addr"
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
RUN mkdir -p "/go/src" "/go/bin" && chmod -R 777 "/go"

# Download TensorFlow model and test files
RUN rm -rf /tmp/* && mkdir -p /tmp/photoprism && \
Expand Down
104 changes: 49 additions & 55 deletions docker/photoprism/Dockerfile
@@ -1,4 +1,4 @@
FROM photoprism/development:20210422 as build
FROM photoprism/development:20210515 as build

# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"
Expand All @@ -8,10 +8,56 @@ COPY . .
RUN make dep build-js install

# Same base image as photoprism/development
FROM ubuntu:20.10
FROM ubuntu:21.04

# Set environment variables
ENV DEBIAN_FRONTEND noninteractive
# see https://docs.photoprism.org/getting-started/config-options/
ENV DEBIAN_FRONTEND="noninteractive" \
TF_CPP_MIN_LOG_LEVEL="2" \
PATH="/photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
TMPDIR="/tmp" \
PHOTOPRISM_ASSETS_PATH="/photoprism/assets" \
PHOTOPRISM_STORAGE_PATH="/photoprism/storage" \
PHOTOPRISM_BACKUP_PATH="/var/lib/photoprism" \
PHOTOPRISM_ORIGINALS_PATH="/photoprism/originals" \
PHOTOPRISM_IMPORT_PATH="/photoprism/import" \
PHOTOPRISM_LOG_FILENAME="/photoprism/photoprism.log" \
PHOTOPRISM_PID_FILENAME="/photoprism/photoprism.pid" \
PHOTOPRISM_DEBUG="false" \
PHOTOPRISM_PUBLIC="false" \
PHOTOPRISM_READONLY="false" \
PHOTOPRISM_UPLOAD_NSFW="true" \
PHOTOPRISM_DETECT_NSFW="false" \
PHOTOPRISM_EXPERIMENTAL="false" \
PHOTOPRISM_SITE_URL="http://localhost:2342/" \
PHOTOPRISM_SITE_TITLE="PhotoPrism" \
PHOTOPRISM_SITE_CAPTION="Browse Your Life" \
PHOTOPRISM_SITE_DESCRIPTION="" \
PHOTOPRISM_SITE_AUTHOR="" \
PHOTOPRISM_HTTP_HOST="0.0.0.0" \
PHOTOPRISM_HTTP_PORT=2342 \
PHOTOPRISM_DATABASE_DRIVER="sqlite" \
PHOTOPRISM_DATABASE_SERVER="" \
PHOTOPRISM_DATABASE_NAME="photoprism" \
PHOTOPRISM_DATABASE_USER="photoprism" \
PHOTOPRISM_DATABASE_PASSWORD="" \
PHOTOPRISM_DISABLE_WEBDAV="false" \
PHOTOPRISM_DISABLE_SETTINGS="false" \
PHOTOPRISM_DISABLE_BACKUPS="false" \
PHOTOPRISM_DISABLE_EXIFTOOL="false" \
PHOTOPRISM_DISABLE_PLACES="false" \
PHOTOPRISM_DISABLE_TENSORFLOW="false" \
PHOTOPRISM_DARKTABLE_PRESETS="false" \
PHOTOPRISM_THUMB_FILTER="lanczos" \
PHOTOPRISM_THUMB_UNCACHED="false" \
PHOTOPRISM_THUMB_SIZE=2048 \
PHOTOPRISM_THUMB_SIZE_UNCACHED=7680 \
PHOTOPRISM_JPEG_SIZE=7680 \
PHOTOPRISM_JPEG_QUALITY=92 \
PHOTOPRISM_WORKERS=0 \
PHOTOPRISM_WAKEUP_INTERVAL=900 \
PHOTOPRISM_AUTO_INDEX=300 \
PHOTOPRISM_AUTO_IMPORT=300

# Configure apt-get
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
Expand Down Expand Up @@ -56,58 +102,6 @@ RUN ldconfig
RUN umask 0000 && useradd photoprism -m -d /photoprism
WORKDIR /photoprism

ENV TF_CPP_MIN_LOG_LEVEL 2

ENV PATH /photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV TMPDIR /tmp

# Storage path names
ENV PHOTOPRISM_ASSETS_PATH="/photoprism/assets" \
PHOTOPRISM_STORAGE_PATH="/photoprism/storage" \
PHOTOPRISM_BACKUP_PATH="/var/lib/photoprism" \
PHOTOPRISM_ORIGINALS_PATH="/photoprism/originals" \
PHOTOPRISM_IMPORT_PATH="/photoprism/import" \
PHOTOPRISM_LOG_FILENAME="/photoprism/photoprism.log" \
PHOTOPRISM_PID_FILENAME="/photoprism/photoprism.pid"

# Defaults for common config values
# See https://docs.photoprism.org/getting-started/config-options/
ENV PHOTOPRISM_DEBUG="false" \
PHOTOPRISM_PUBLIC="false" \
PHOTOPRISM_READONLY="false" \
PHOTOPRISM_UPLOAD_NSFW="true" \
PHOTOPRISM_DETECT_NSFW="false" \
PHOTOPRISM_EXPERIMENTAL="false" \
PHOTOPRISM_SITE_URL="http://localhost:2342/" \
PHOTOPRISM_SITE_TITLE="PhotoPrism" \
PHOTOPRISM_SITE_CAPTION="Browse Your Life" \
PHOTOPRISM_SITE_DESCRIPTION="" \
PHOTOPRISM_SITE_AUTHOR="" \
PHOTOPRISM_HTTP_HOST="0.0.0.0" \
PHOTOPRISM_HTTP_PORT=2342 \
PHOTOPRISM_DATABASE_DRIVER="sqlite" \
PHOTOPRISM_DATABASE_SERVER="" \
PHOTOPRISM_DATABASE_NAME="photoprism" \
PHOTOPRISM_DATABASE_USER="photoprism" \
PHOTOPRISM_DATABASE_PASSWORD="" \
PHOTOPRISM_DISABLE_WEBDAV="false" \
PHOTOPRISM_DISABLE_SETTINGS="false" \
PHOTOPRISM_DISABLE_BACKUPS="false" \
PHOTOPRISM_DISABLE_EXIFTOOL="false" \
PHOTOPRISM_DISABLE_PLACES="false" \
PHOTOPRISM_DISABLE_TENSORFLOW="false" \
PHOTOPRISM_DARKTABLE_PRESETS="false" \
PHOTOPRISM_THUMB_FILTER="lanczos" \
PHOTOPRISM_THUMB_UNCACHED="false" \
PHOTOPRISM_THUMB_SIZE=2048 \
PHOTOPRISM_THUMB_SIZE_UNCACHED=7680 \
PHOTOPRISM_JPEG_SIZE=7680 \
PHOTOPRISM_JPEG_QUALITY=92 \
PHOTOPRISM_WORKERS=0 \
PHOTOPRISM_WAKEUP_INTERVAL=900 \
PHOTOPRISM_AUTO_INDEX=300 \
PHOTOPRISM_AUTO_IMPORT=300

# Copy files to /photoprism
COPY --from=build /root/.local/bin/photoprism /photoprism/bin/photoprism
COPY --from=build /root/.photoprism/assets /photoprism/assets
Expand Down

0 comments on commit 77ddcec

Please sign in to comment.