photoprism/docker/photoprism-arm64/Dockerfile
Michael Mayer f99bcb0bdf Docker: Refactor directory structure for ARM64 #109
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-01-19 23:28:59 +01:00

177 lines
5.1 KiB
Docker

FROM ubuntu:18.04 as build
LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"
ARG BUILD_TAG
ENV DEBIAN_FRONTEND noninteractive
# Configure apt-get
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry
RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends
RUN echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes
RUN echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissin
# Install dev / build dependencies
RUN apt-get update && apt-get upgrade && \
apt-get install \
build-essential \
curl \
chrpath \
libssl-dev \
libxft-dev \
libfreetype6 \
libfreetype6-dev \
libfontconfig1 \
libfontconfig1-dev \
libhdf5-serial-dev \
libpng-dev \
libzmq3-dev \
pkg-config \
software-properties-common \
rsync \
unzip \
zip \
g++ \
gcc \
libc6-dev \
gpg-agent \
apt-utils \
make \
nano \
wget \
git \
mysql-client \
tzdata \
gconf-service \
chromium-browser \
firefox \
libheif-examples \
darktable \
exiftool
# Install & configure TensorFlow for C
#
# Big thank you to Guy Sheffer for building this!
# https://github.com/guysoft
#
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/arm64/libtensorflow-arm64-1.14.0.tar.gz" | \
tar -C "/usr" -xz
RUN ldconfig
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get update && \
apt-get install nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install and configure NodeJS Package Manager (npm)
ENV NODE_ENV production
RUN npm install --unsafe-perm=true --allow-root -g npm testcafe chromedriver
RUN npm config set cache ~/.cache/npm
# Install Go
ENV GOLANG_VERSION 1.13.6
RUN set -eux; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \
wget -O go.tgz "$url"; \
echo "0a18125c4ed80f9c3045cf92384670907c4796b43ed63c4307210fe93e5bbca5 *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:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV GO111MODULE on
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
# Download TensorFlow model and test files
RUN rm -rf /tmp/* && mkdir -p /tmp/photoprism
RUN wget "https://dl.photoprism.org/tensorflow/nsfw.zip?${BUILD_TAG}" -O /tmp/photoprism/nsfw.zip
RUN wget "https://dl.photoprism.org/tensorflow/nasnet.zip?${BUILD_TAG}" -O /tmp/photoprism/nasnet.zip
RUN wget "https://dl.photoprism.org/fixtures/testdata.zip?${BUILD_TAG}" -O /tmp/photoprism/testdata.zip
# Install goimports and richgo (colorizes "go test" output)
RUN env GO111MODULE=off /usr/local/go/bin/go get -u golang.org/x/tools/cmd/goimports
RUN env GO111MODULE=off /usr/local/go/bin/go get -u github.com/kyoh86/richgo
RUN echo "alias go=richgo" > /root/.bash_aliases
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"
COPY . .
# Build PhotoPrism
RUN make dep build-js install
# Same base image as photoprism/development
FROM ubuntu:18.04
# Set environment variables
ENV DEBIAN_FRONTEND noninteractive
# Install additional distribution packages
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
unzip \
nano \
wget \
ca-certificates \
tzdata \
libheif-examples \
darktable \
exiftool && \
apt-get update && \
apt-get upgrade && \
apt-get dist-upgrade && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy dependencies
COPY --from=build /usr/lib/libtensorflow.so /usr/lib/libtensorflow.so
COPY --from=build /usr/lib/libtensorflow_framework.so /usr/lib/libtensorflow_framework.so
RUN ldconfig
# Create and configure photoprism user
RUN useradd -ms /bin/bash photoprism
USER photoprism
WORKDIR /home/photoprism
ENV PATH /home/photoprism/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV TF_CPP_MIN_LOG_LEVEL 2
ENV PHOTOPRISM_CONFIG_FILE /home/photoprism/.config/photoprism/photoprism.yml
# Copy assets to /home/photoprism
COPY --chown=photoprism --from=build /root/.local/bin/photoprism /home/photoprism/.local/bin/photoprism
COPY --chown=photoprism --from=build /root/.local/share/photoprism /home/photoprism/.local/share/photoprism
COPY --chown=photoprism --from=build /root/.config/photoprism /home/photoprism/.config/photoprism
# Create directories
RUN mkdir -p /home/photoprism/.cache/photoprism \
/home/photoprism/Pictures/Originals \
/home/photoprism/Pictures/Import \
/home/photoprism/Pictures/Export
# Fix permissions
USER root
RUN chown -R photoprism:photoprism /home/photoprism
USER photoprism
# Show photoprism version
RUN photoprism -v
# Expose http and database ports
EXPOSE 2342 4000
# Run server
CMD photoprism start