Docker: Upgrade base image and improve prod image #1158 #1432

This commit contains a few improvements discussed in PR #1432
with the primary goal to reduce the Docker image size.
Go has been upgraded from v1.16.4 to v1.16.6 as well.
This commit is contained in:
Michael Mayer 2021-07-15 16:05:50 +02:00
parent 871a5301f6
commit b245695eb7
4 changed files with 20 additions and 22 deletions

View file

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

View file

@ -21,7 +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 && -qq apt-get dist-upgrade && \
RUN apt-get update && apt-get -qq dist-upgrade && \
apt-get -qq install -y --no-install-recommends \
build-essential \
ca-certificates \
@ -69,7 +69,8 @@ RUN apt-get update && -qq apt-get dist-upgrade && \
apache2-utils \
fonts-roboto \
sudo && \
[ "$TARGETARCH" = "arm" ] || apt-get install darktable
[ "$TARGETARCH" = "arm" ] || apt-get -qq install darktable; \
apt-get -y autoremove && apt-get -y autoclean && apt-get clean
# Set environment variables
ENV LD_LIBRARY_PATH="/root/.local/lib:/usr/local/lib:/usr/lib:/lib" \
@ -93,17 +94,17 @@ 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 dist-upgrade && \
apt-get install chromium-browser chromium-codecs-ffmpeg-extra nodejs && \
apt-get autoremove && \
apt-get -qq dist-upgrade && \
apt-get -qq install chromium-browser chromium-codecs-ffmpeg-extra nodejs && \
apt-get -y autoremove && \
apt-get -y autoclean && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
umask 0000
rm -rf /var/lib/apt/lists/*
# Install NodeJS & NPM
RUN npm install --unsafe-perm=true --allow-root -g npm && \
[ "$TARGETARCH" = "arm" ] || npm install --unsafe-perm=true --allow-root -g testcafe chromedriver && \
npm config set cache ~/.cache/npm
RUN umask 0000 && npm install --unsafe-perm=true --allow-root -g npm && npm config set cache ~/.cache/npm && \
[ "$TARGETARCH" = "arm" ] || npm install --unsafe-perm=true --allow-root -g testcafe chromedriver;
# Install Go
RUN /root/.local/bin/install-go.sh ${TARGETARCH}

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20210628 as build
FROM photoprism/development:20210715 as build
ARG TARGETARCH
ARG TARGETPLATFORM
@ -53,10 +53,8 @@ RUN apt-get update && apt-get -qq dist-upgrade && \
ffmpeg \
ffmpegthumbnailer \
libavcodec-extra && \
[ "$TARGETARCH" = "arm" ] || apt-get install darktable
# Remove files to reduce image size
RUN apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*
[ "$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/
@ -129,8 +127,7 @@ RUN mkdir -m 777 -p \
/photoprism/storage/config \
/photoprism/storage/cache && \
chown -Rf photoprism:photoprism /photoprism /var/lib/photoprism /tmp/photoprism && \
chmod -Rf a+rw /photoprism /var/lib/photoprism /tmp/photoprism && \
find /photoprism -type d -print0 | xargs -0 chmod 777
chmod -Rf a+rwx /photoprism /var/lib/photoprism /tmp/photoprism
# Show photoprism version
RUN photoprism -v

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
GOLANG_VERSION=1.16.4
GOLANG_VERSION=1.16.6
if [[ -z $1 ]]; then
echo "Please define architecture and version" 1>&2
@ -9,13 +9,13 @@ else
set -eux;
if [[ $1 == "amd64" ]]; then
URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-$1.tar.gz"
CHECKSUM="7154e88f5a8047aad4b80ebace58a059e36e7e2e4eb3b383127a28c711b4ff59 *go.tgz"
CHECKSUM="be333ef18b3016e9d7cb7b1ff1fdb0cac800ca0be4cf2290fe613b3d069dfe0d *go.tgz"
elif [[ $1 == "arm64" ]]; then
URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-$1.tar.gz"
CHECKSUM="8b18eb05ddda2652d69ab1b1dd1f40dd731799f43c6a58b512ad01ae5b5bba21 *go.tgz"
CHECKSUM="9e38047463da6daecab9017cd0599f33f84991e68263752cfab49253bbc98c30 *go.tgz"
elif [[ $1 == "arm" ]]; then
URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz"
CHECKSUM="a53391a800ddec749ee90d38992babb27b95cfb864027350c737b9aa8e069494 *go.tgz"
CHECKSUM="b1ca342e81897da3f25da4e75ae29b267db1674fe7222d9bfc4c666bcf6fce69 *go.tgz"
else
echo "cpu architecture not supported by now" 1>&2
exit 1