2023-06-16 09:10:08 -07:00
|
|
|
# syntax=docker/dockerfile:1
|
2023-01-30 10:05:50 -08:00
|
|
|
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md
|
2022-05-04 15:05:54 -07:00
|
|
|
|
2023-02-06 09:35:34 -08:00
|
|
|
# Stage: compile-frontend
|
|
|
|
|
# Purpose: Compiles the frontend
|
|
|
|
|
# Notes:
|
2025-03-11 10:59:44 -07:00
|
|
|
# - Does PNPM stuff with Typescript and such
|
2023-09-14 10:13:25 -07:00
|
|
|
FROM --platform=$BUILDPLATFORM docker.io/node:20-bookworm-slim AS compile-frontend
|
2022-04-30 10:33:09 -07:00
|
|
|
|
|
|
|
|
COPY ./src-ui /src/src-ui
|
|
|
|
|
|
|
|
|
|
WORKDIR /src/src-ui
|
|
|
|
|
RUN set -eux \
|
2025-03-11 10:59:44 -07:00
|
|
|
&& npm update -g pnpm \
|
|
|
|
|
&& npm install -g corepack@latest \
|
|
|
|
|
&& corepack enable \
|
|
|
|
|
&& pnpm install
|
2024-06-26 20:02:52 -07:00
|
|
|
|
|
|
|
|
ARG PNGX_TAG_VERSION=
|
|
|
|
|
# Add the tag to the environment file if its a tagged dev build
|
|
|
|
|
RUN set -eux && \
|
|
|
|
|
case "${PNGX_TAG_VERSION}" in \
|
2024-10-14 07:55:03 -07:00
|
|
|
dev|beta|fix*|feature*) \
|
2025-06-19 08:29:34 -07:00
|
|
|
sed -i -E "s/tag: '([a-z\.]+)'/tag: '${PNGX_TAG_VERSION}'/g" /src/src-ui/src/environments/environment.prod.ts \
|
2024-06-26 20:02:52 -07:00
|
|
|
;; \
|
|
|
|
|
esac
|
|
|
|
|
|
2022-04-30 10:33:09 -07:00
|
|
|
RUN set -eux \
|
|
|
|
|
&& ./node_modules/.bin/ng build --configuration production
|
2022-04-18 08:18:20 -07:00
|
|
|
|
2025-02-07 11:25:54 -08:00
|
|
|
# Stage: s6-overlay-base
|
|
|
|
|
# Purpose: Installs s6-overlay and rootfs
|
|
|
|
|
# Comments:
|
|
|
|
|
# - Don't leave anything extra in here either
|
2025-08-26 14:59:05 -07:00
|
|
|
FROM ghcr.io/astral-sh/uv:0.8.13-python3.12-bookworm-slim AS s6-overlay-base
|
2025-02-07 11:25:54 -08:00
|
|
|
|
|
|
|
|
WORKDIR /usr/src/s6
|
|
|
|
|
|
|
|
|
|
# https://github.com/just-containers/s6-overlay#customizing-s6-overlay-behaviour
|
|
|
|
|
ENV \
|
|
|
|
|
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
|
|
|
|
|
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
|
|
|
|
|
S6_VERBOSITY=1 \
|
|
|
|
|
PATH=/command:$PATH
|
|
|
|
|
|
|
|
|
|
# Buildx provided, must be defined to use though
|
|
|
|
|
ARG TARGETARCH
|
|
|
|
|
ARG TARGETVARIANT
|
|
|
|
|
# Lock this version
|
2025-05-07 08:56:11 -07:00
|
|
|
ARG S6_OVERLAY_VERSION=3.2.1.0
|
2025-02-07 11:25:54 -08:00
|
|
|
|
|
|
|
|
ARG S6_BUILD_TIME_PKGS="curl \
|
|
|
|
|
xz-utils"
|
|
|
|
|
|
|
|
|
|
RUN set -eux \
|
|
|
|
|
&& echo "Installing build time packages" \
|
|
|
|
|
&& apt-get update \
|
|
|
|
|
&& apt-get install --yes --quiet --no-install-recommends ${S6_BUILD_TIME_PKGS} \
|
|
|
|
|
&& echo "Determining arch" \
|
|
|
|
|
&& S6_ARCH="" \
|
|
|
|
|
&& if [ "${TARGETARCH}${TARGETVARIANT}" = "amd64" ]; then S6_ARCH="x86_64"; \
|
|
|
|
|
elif [ "${TARGETARCH}${TARGETVARIANT}" = "arm64" ]; then S6_ARCH="aarch64"; fi\
|
|
|
|
|
&& if [ -z "${S6_ARCH}" ]; then { echo "Error: Not able to determine arch"; exit 1; }; fi \
|
|
|
|
|
&& echo "Installing s6-overlay for ${S6_ARCH}" \
|
|
|
|
|
&& curl --fail --silent --no-progress-meter --show-error --location --remote-name-all --parallel --parallel-max 4 \
|
|
|
|
|
"https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" \
|
|
|
|
|
"https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz.sha256" \
|
|
|
|
|
"https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz" \
|
|
|
|
|
"https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz.sha256" \
|
|
|
|
|
&& echo "Validating s6-archive checksums" \
|
|
|
|
|
&& sha256sum --check ./*.sha256 \
|
|
|
|
|
&& echo "Unpacking archives" \
|
|
|
|
|
&& tar --directory / -Jxpf s6-overlay-noarch.tar.xz \
|
|
|
|
|
&& tar --directory / -Jxpf s6-overlay-${S6_ARCH}.tar.xz \
|
|
|
|
|
&& echo "Removing downloaded archives" \
|
|
|
|
|
&& rm ./*.tar.xz \
|
|
|
|
|
&& rm ./*.sha256 \
|
|
|
|
|
&& echo "Cleaning up image" \
|
|
|
|
|
&& apt-get --yes purge ${S6_BUILD_TIME_PKGS} \
|
|
|
|
|
&& apt-get --yes autoremove --purge \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Copy our service defs and filesystem
|
|
|
|
|
COPY ./docker/rootfs /
|
|
|
|
|
|
2023-02-06 09:35:34 -08:00
|
|
|
# Stage: main-app
|
|
|
|
|
# Purpose: The final image
|
|
|
|
|
# Comments:
|
|
|
|
|
# - Don't leave anything extra in here
|
2025-02-07 11:25:54 -08:00
|
|
|
FROM s6-overlay-base AS main-app
|
2021-07-04 00:15:29 +02:00
|
|
|
|
2022-03-26 13:21:17 -07:00
|
|
|
LABEL org.opencontainers.image.authors="paperless-ngx team <hello@paperless-ngx.com>"
|
2022-12-03 02:08:51 -08:00
|
|
|
LABEL org.opencontainers.image.documentation="https://docs.paperless-ngx.com/"
|
2022-03-26 13:21:17 -07:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/paperless-ngx/paperless-ngx"
|
|
|
|
|
LABEL org.opencontainers.image.url="https://github.com/paperless-ngx/paperless-ngx"
|
|
|
|
|
LABEL org.opencontainers.image.licenses="GPL-3.0-only"
|
2021-02-12 16:53:51 +01:00
|
|
|
|
2022-04-18 08:18:20 -07:00
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
2023-10-05 10:51:58 -07:00
|
|
|
# Buildx provided, must be defined to use though
|
|
|
|
|
ARG TARGETARCH
|
|
|
|
|
|
|
|
|
|
# Can be workflow provided, defaults set for manual building
|
2025-02-12 09:28:24 -08:00
|
|
|
ARG JBIG2ENC_VERSION=0.30
|
2024-04-18 15:16:44 -07:00
|
|
|
ARG QPDF_VERSION=11.9.0
|
2024-05-29 09:43:33 -07:00
|
|
|
ARG GS_VERSION=10.03.1
|
2023-10-05 10:51:58 -07:00
|
|
|
|
2024-02-07 18:45:59 -08:00
|
|
|
# Set Python environment variables
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
|
PYTHONUNBUFFERED=1 \
|
2025-03-04 08:15:51 -08:00
|
|
|
# Ignore warning from Whitenoise about async iterators
|
2024-03-04 09:26:25 -08:00
|
|
|
PYTHONWARNINGS="ignore:::django.http.response:517" \
|
2025-03-04 08:15:51 -08:00
|
|
|
PNGX_CONTAINERIZED=1 \
|
|
|
|
|
# https://docs.astral.sh/uv/reference/settings/#link-mode
|
|
|
|
|
UV_LINK_MODE=copy \
|
|
|
|
|
UV_CACHE_DIR=/cache/uv/
|
2024-02-07 18:45:59 -08:00
|
|
|
|
2022-05-04 15:05:54 -07:00
|
|
|
#
|
|
|
|
|
# Begin installation and configuration
|
|
|
|
|
# Order the steps below from least often changed to most
|
|
|
|
|
#
|
|
|
|
|
|
2022-04-18 08:18:20 -07:00
|
|
|
# Packages need for running
|
|
|
|
|
ARG RUNTIME_PACKAGES="\
|
2022-11-29 12:16:51 -08:00
|
|
|
# General utils
|
2022-04-18 08:18:20 -07:00
|
|
|
curl \
|
2022-11-29 12:16:51 -08:00
|
|
|
# Docker specific
|
|
|
|
|
gosu \
|
|
|
|
|
# Timezones support
|
|
|
|
|
tzdata \
|
2022-04-18 08:18:20 -07:00
|
|
|
# fonts for text file thumbnail generation
|
|
|
|
|
fonts-liberation \
|
|
|
|
|
gettext \
|
|
|
|
|
ghostscript \
|
|
|
|
|
gnupg \
|
|
|
|
|
icc-profiles-free \
|
|
|
|
|
imagemagick \
|
2022-11-29 12:16:51 -08:00
|
|
|
# PostgreSQL
|
2022-04-18 08:18:20 -07:00
|
|
|
postgresql-client \
|
2022-11-29 12:16:51 -08:00
|
|
|
# MySQL / MariaDB
|
2022-05-31 22:18:43 -06:00
|
|
|
mariadb-client \
|
2022-04-18 08:18:20 -07:00
|
|
|
# OCRmyPDF dependencies
|
|
|
|
|
tesseract-ocr \
|
|
|
|
|
tesseract-ocr-eng \
|
|
|
|
|
tesseract-ocr-deu \
|
|
|
|
|
tesseract-ocr-fra \
|
|
|
|
|
tesseract-ocr-ita \
|
|
|
|
|
tesseract-ocr-spa \
|
2022-11-29 12:16:51 -08:00
|
|
|
unpaper \
|
2022-07-28 15:36:24 -07:00
|
|
|
pngquant \
|
|
|
|
|
jbig2dec \
|
2023-09-09 16:08:00 -07:00
|
|
|
# lxml
|
2022-11-29 12:16:51 -08:00
|
|
|
libxml2 \
|
|
|
|
|
libxslt1.1 \
|
2023-09-09 16:08:00 -07:00
|
|
|
# itself
|
2023-06-05 10:19:32 -07:00
|
|
|
qpdf \
|
2022-04-18 08:18:20 -07:00
|
|
|
# Mime type detection
|
2022-11-29 12:16:51 -08:00
|
|
|
file \
|
|
|
|
|
libmagic1 \
|
|
|
|
|
media-types \
|
2022-04-18 08:18:20 -07:00
|
|
|
zlib1g \
|
|
|
|
|
# Barcode splitter
|
|
|
|
|
libzbar0 \
|
2023-09-09 16:08:00 -07:00
|
|
|
poppler-utils"
|
2022-04-18 08:18:20 -07:00
|
|
|
|
2022-05-04 15:05:54 -07:00
|
|
|
# Install basic runtime packages.
|
|
|
|
|
# These change very infrequently
|
|
|
|
|
RUN set -eux \
|
|
|
|
|
echo "Installing system packages" \
|
|
|
|
|
&& apt-get update \
|
|
|
|
|
&& apt-get install --yes --quiet --no-install-recommends ${RUNTIME_PACKAGES} \
|
2023-10-05 10:51:58 -07:00
|
|
|
&& echo "Installing pre-built updates" \
|
2025-01-29 13:00:49 -08:00
|
|
|
&& curl --fail --silent --no-progress-meter --show-error --location --remote-name-all --parallel --parallel-max 4 \
|
|
|
|
|
https://github.com/paperless-ngx/builder/releases/download/qpdf-${QPDF_VERSION}/libqpdf29_${QPDF_VERSION}-1_${TARGETARCH}.deb \
|
|
|
|
|
https://github.com/paperless-ngx/builder/releases/download/qpdf-${QPDF_VERSION}/qpdf_${QPDF_VERSION}-1_${TARGETARCH}.deb \
|
|
|
|
|
https://github.com/paperless-ngx/builder/releases/download/ghostscript-${GS_VERSION}/libgs10_${GS_VERSION}.dfsg-1_${TARGETARCH}.deb \
|
|
|
|
|
https://github.com/paperless-ngx/builder/releases/download/ghostscript-${GS_VERSION}/ghostscript_${GS_VERSION}.dfsg-1_${TARGETARCH}.deb \
|
|
|
|
|
https://github.com/paperless-ngx/builder/releases/download/ghostscript-${GS_VERSION}/libgs10-common_${GS_VERSION}.dfsg-1_all.deb \
|
|
|
|
|
https://github.com/paperless-ngx/builder/releases/download/jbig2enc-${JBIG2ENC_VERSION}/jbig2enc_${JBIG2ENC_VERSION}-1_${TARGETARCH}.deb \
|
2023-10-05 10:51:58 -07:00
|
|
|
&& echo "Installing qpdf ${QPDF_VERSION}" \
|
|
|
|
|
&& dpkg --install ./libqpdf29_${QPDF_VERSION}-1_${TARGETARCH}.deb \
|
|
|
|
|
&& dpkg --install ./qpdf_${QPDF_VERSION}-1_${TARGETARCH}.deb \
|
|
|
|
|
&& echo "Installing Ghostscript ${GS_VERSION}" \
|
2024-06-11 08:38:07 -07:00
|
|
|
&& dpkg --install ./libgs10-common_${GS_VERSION}.dfsg-1_all.deb \
|
|
|
|
|
&& dpkg --install ./libgs10_${GS_VERSION}.dfsg-1_${TARGETARCH}.deb \
|
|
|
|
|
&& dpkg --install ./ghostscript_${GS_VERSION}.dfsg-1_${TARGETARCH}.deb \
|
2023-10-05 10:51:58 -07:00
|
|
|
&& echo "Installing jbig2enc" \
|
|
|
|
|
&& dpkg --install ./jbig2enc_${JBIG2ENC_VERSION}-1_${TARGETARCH}.deb \
|
2025-02-07 11:25:54 -08:00
|
|
|
&& echo "Configuring imagemagick" \
|
|
|
|
|
&& cp /etc/ImageMagick-6/paperless-policy.xml /etc/ImageMagick-6/policy.xml \
|
2023-10-05 10:51:58 -07:00
|
|
|
&& echo "Cleaning up image layer" \
|
|
|
|
|
&& rm --force --verbose *.deb \
|
2025-02-07 11:25:54 -08:00
|
|
|
&& rm --recursive --force --verbose /var/lib/apt/lists/*
|
2021-02-12 16:53:51 +01:00
|
|
|
|
2022-07-20 09:44:12 -07:00
|
|
|
WORKDIR /usr/src/paperless/src/
|
|
|
|
|
|
2022-05-04 15:05:54 -07:00
|
|
|
# Python dependencies
|
|
|
|
|
# Change pretty frequently
|
2025-03-04 08:15:51 -08:00
|
|
|
COPY --chown=1000:1000 ["pyproject.toml", "uv.lock", "/usr/src/paperless/src/"]
|
2021-02-12 16:53:51 +01:00
|
|
|
|
2022-05-04 15:05:54 -07:00
|
|
|
# Packages needed only for building a few quick Python
|
|
|
|
|
# dependencies
|
|
|
|
|
ARG BUILD_PACKAGES="\
|
|
|
|
|
build-essential \
|
2023-09-05 13:15:24 -07:00
|
|
|
# https://github.com/PyMySQL/mysqlclient#linux
|
2023-07-20 11:02:33 -07:00
|
|
|
default-libmysqlclient-dev \
|
|
|
|
|
pkg-config"
|
2022-05-04 15:05:54 -07:00
|
|
|
|
2023-06-16 09:10:08 -07:00
|
|
|
# hadolint ignore=DL3042
|
2025-03-04 08:15:51 -08:00
|
|
|
RUN --mount=type=cache,target=${UV_CACHE_DIR},id=python-cache \
|
2023-06-16 09:10:08 -07:00
|
|
|
set -eux \
|
2022-05-04 15:05:54 -07:00
|
|
|
&& echo "Installing build system packages" \
|
|
|
|
|
&& apt-get update \
|
|
|
|
|
&& apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \
|
2022-04-18 08:18:20 -07:00
|
|
|
&& echo "Installing Python requirements" \
|
2025-03-04 14:16:09 -08:00
|
|
|
&& uv export --quiet --no-dev --all-extras --format requirements-txt --output-file requirements.txt \
|
2025-03-04 08:15:51 -08:00
|
|
|
&& uv pip install --system --no-python-downloads --python-preference system --requirements requirements.txt \
|
2022-12-02 12:02:56 -08:00
|
|
|
&& echo "Installing NLTK data" \
|
2023-01-14 15:37:27 +01:00
|
|
|
&& python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" snowball_data \
|
|
|
|
|
&& python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" stopwords \
|
2024-08-22 20:32:02 -07:00
|
|
|
&& python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" punkt_tab \
|
2022-04-18 08:18:20 -07:00
|
|
|
&& echo "Cleaning up image" \
|
2023-10-09 14:33:21 -07:00
|
|
|
&& apt-get --yes purge ${BUILD_PACKAGES} \
|
|
|
|
|
&& apt-get --yes autoremove --purge \
|
2022-04-18 08:18:20 -07:00
|
|
|
&& apt-get clean --yes \
|
2024-05-23 13:09:05 -07:00
|
|
|
&& rm --recursive --force --verbose *.whl \
|
2023-10-05 10:51:58 -07:00
|
|
|
&& rm --recursive --force --verbose /var/lib/apt/lists/* \
|
|
|
|
|
&& rm --recursive --force --verbose /tmp/* \
|
|
|
|
|
&& rm --recursive --force --verbose /var/tmp/* \
|
|
|
|
|
&& rm --recursive --force --verbose /var/cache/apt/archives/* \
|
|
|
|
|
&& truncate --size 0 /var/log/*log
|
2020-11-14 12:10:38 +01:00
|
|
|
|
2022-04-30 10:33:09 -07:00
|
|
|
# copy backend
|
2023-10-20 16:22:05 -07:00
|
|
|
COPY --chown=1000:1000 ./src ./
|
2022-04-30 10:33:09 -07:00
|
|
|
|
|
|
|
|
# copy frontend
|
2023-10-20 16:22:05 -07:00
|
|
|
COPY --from=compile-frontend --chown=1000:1000 /src/src/documents/static/frontend/ ./documents/static/frontend/
|
2020-11-14 12:10:38 +01:00
|
|
|
|
|
|
|
|
# add users, setup scripts
|
2023-01-30 10:05:50 -08:00
|
|
|
# Mount the compiled frontend to expected location
|
2022-04-18 08:18:20 -07:00
|
|
|
RUN set -eux \
|
2025-03-26 14:17:10 -07:00
|
|
|
&& sed -i '1s|^#!/usr/bin/env python3|#!/command/with-contenv python3|' manage.py \
|
2023-09-20 11:39:31 -07:00
|
|
|
&& echo "Setting up user/group" \
|
|
|
|
|
&& addgroup --gid 1000 paperless \
|
|
|
|
|
&& useradd --uid 1000 --gid paperless --home-dir /usr/src/paperless paperless \
|
|
|
|
|
&& echo "Creating volume directories" \
|
2023-10-09 14:33:21 -07:00
|
|
|
&& mkdir --parents --verbose /usr/src/paperless/data \
|
|
|
|
|
&& mkdir --parents --verbose /usr/src/paperless/media \
|
|
|
|
|
&& mkdir --parents --verbose /usr/src/paperless/consume \
|
|
|
|
|
&& mkdir --parents --verbose /usr/src/paperless/export \
|
2024-08-29 02:22:44 +02:00
|
|
|
&& echo "Creating gnupg directory" \
|
|
|
|
|
&& mkdir -m700 --verbose /usr/src/paperless/.gnupg \
|
2023-09-20 11:39:31 -07:00
|
|
|
&& echo "Adjusting all permissions" \
|
2023-10-20 16:22:05 -07:00
|
|
|
&& chown --from root:root --changes --recursive paperless:paperless /usr/src/paperless \
|
2023-09-20 11:39:31 -07:00
|
|
|
&& echo "Collecting static files" \
|
2025-02-07 11:25:54 -08:00
|
|
|
&& s6-setuidgid paperless python3 manage.py collectstatic --clear --no-input --link \
|
|
|
|
|
&& s6-setuidgid paperless python3 manage.py compilemessages
|
2022-03-26 13:21:17 -07:00
|
|
|
|
|
|
|
|
VOLUME ["/usr/src/paperless/data", \
|
|
|
|
|
"/usr/src/paperless/media", \
|
|
|
|
|
"/usr/src/paperless/consume", \
|
|
|
|
|
"/usr/src/paperless/export"]
|
2021-01-02 01:57:26 +01:00
|
|
|
|
2025-02-07 11:25:54 -08:00
|
|
|
ENTRYPOINT ["/init"]
|
2022-03-26 13:21:17 -07:00
|
|
|
|
2020-12-28 17:20:07 +01:00
|
|
|
EXPOSE 8000
|
2020-11-14 12:10:38 +01:00
|
|
|
|
2025-07-20 15:31:49 +02:00
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --retries=5 CMD [ "curl", "-fs", "-S", "-L", "--max-time", "2", "http://localhost:8000" ]
|