mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
i fixed the docker
This commit is contained in:
parent
03bd2b7328
commit
70c1a0e717
115
Dockerfile
115
Dockerfile
@ -1,74 +1,71 @@
|
|||||||
FROM alpine:3.11
|
###############################################################################
|
||||||
|
### Front end ###
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
LABEL maintainer="The Paperless Project https://github.com/the-paperless-project/paperless" \
|
FROM node:current AS frontend
|
||||||
contributors="Guy Addadi <addadi@gmail.com>, Pit Kleyersburg <pitkley@googlemail.com>, \
|
|
||||||
Sven Fischer <git-dev@linux4tw.de>"
|
|
||||||
|
|
||||||
# Copy Pipfiles file, init script and gunicorn.conf
|
WORKDIR /usr/src/paperless/src-ui/
|
||||||
COPY Pipfile* /usr/src/paperless/
|
|
||||||
COPY scripts/docker-entrypoint.sh /sbin/docker-entrypoint.sh
|
|
||||||
COPY scripts/gunicorn.conf /usr/src/paperless/
|
|
||||||
|
|
||||||
# Set export and consumption directories
|
COPY src-ui/package* ./
|
||||||
ENV PAPERLESS_EXPORT_DIR=/export \
|
RUN npm install
|
||||||
PAPERLESS_CONSUMPTION_DIR=/consume
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
COPY src-ui .
|
||||||
bash \
|
RUN node_modules/.bin/ng build --prod --output-hashing none
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
### Back end ###
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
FROM python:3.8-slim
|
||||||
|
|
||||||
|
WORKDIR /usr/src/paperless/
|
||||||
|
|
||||||
|
COPY Pipfile* ./
|
||||||
|
|
||||||
|
#Dependencies
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get -y --no-install-recommends install \
|
||||||
|
build-essential \
|
||||||
curl \
|
curl \
|
||||||
ghostscript \
|
ghostscript \
|
||||||
gnupg \
|
gnupg \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
libmagic \
|
libmagic-dev \
|
||||||
libpq \
|
libpoppler-cpp-dev \
|
||||||
|
libpq-dev \
|
||||||
optipng \
|
optipng \
|
||||||
poppler \
|
|
||||||
python3 \
|
|
||||||
shadow \
|
|
||||||
sudo \
|
sudo \
|
||||||
tesseract-ocr \
|
tesseract-ocr \
|
||||||
|
tesseract-ocr-eng \
|
||||||
|
tesseract-ocr-deu \
|
||||||
|
tesseract-ocr-fra \
|
||||||
|
tesseract-ocr-ita \
|
||||||
|
tesseract-ocr-spa \
|
||||||
tzdata \
|
tzdata \
|
||||||
unpaper && \
|
unpaper \
|
||||||
apk add --no-cache --virtual .build-dependencies \
|
&& pip install --upgrade pipenv \
|
||||||
g++ \
|
&& pipenv install --system --deploy \
|
||||||
gcc \
|
&& apt-get -y purge build-essential \
|
||||||
jpeg-dev \
|
&& apt-get -y autoremove --purge \
|
||||||
musl-dev \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
poppler-dev \
|
|
||||||
postgresql-dev \
|
|
||||||
python3-dev \
|
|
||||||
zlib-dev && \
|
|
||||||
# Install python dependencies
|
|
||||||
python3 -m ensurepip && \
|
|
||||||
rm -r /usr/lib/python*/ensurepip && \
|
|
||||||
cd /usr/src/paperless && \
|
|
||||||
pip3 install --upgrade pip pipenv && \
|
|
||||||
pipenv install --system --deploy && \
|
|
||||||
# Remove build dependencies
|
|
||||||
apk del .build-dependencies && \
|
|
||||||
# Create the consumption directory
|
|
||||||
mkdir -p $PAPERLESS_CONSUMPTION_DIR && \
|
|
||||||
# Create user
|
|
||||||
addgroup -g 1000 paperless && \
|
|
||||||
adduser -D -u 1000 -G paperless -h /usr/src/paperless paperless && \
|
|
||||||
chown -Rh paperless:paperless /usr/src/paperless && \
|
|
||||||
mkdir -p $PAPERLESS_EXPORT_DIR && \
|
|
||||||
# Avoid setrlimit warnings
|
|
||||||
# See: https://gitlab.alpinelinux.org/alpine/aports/issues/11122
|
|
||||||
echo 'Set disable_coredump false' >> /etc/sudo.conf && \
|
|
||||||
# Setup entrypoint
|
|
||||||
chmod 755 /sbin/docker-entrypoint.sh
|
|
||||||
|
|
||||||
WORKDIR /usr/src/paperless/src
|
# # Copy application
|
||||||
# Mount volumes and set Entrypoint
|
COPY scripts/gunicorn.conf.py ./
|
||||||
VOLUME ["/usr/src/paperless/data", "/usr/src/paperless/media", "/consume", "/export"]
|
COPY src/ ./src/
|
||||||
|
COPY --from=frontend /usr/src/paperless/src-ui/dist/paperless-ui/ ./src/documents/static/
|
||||||
|
|
||||||
|
RUN addgroup --gid 1000 paperless && \
|
||||||
|
useradd --uid 1000 --gid paperless --home-dir /usr/src/paperless paperless && \
|
||||||
|
chown -R paperless:paperless .
|
||||||
|
|
||||||
|
WORKDIR /usr/src/paperless/src/
|
||||||
|
|
||||||
|
RUN sudo -HEu paperless python3 manage.py collectstatic --clear --no-input
|
||||||
|
|
||||||
|
VOLUME ["/usr/src/paperless/data", "/usr/src/paperless/consume", "/usr/src/paperless/export"]
|
||||||
|
|
||||||
|
COPY scripts/docker-entrypoint.sh /sbin/docker-entrypoint.sh
|
||||||
|
RUN chmod 755 /sbin/docker-entrypoint.sh
|
||||||
ENTRYPOINT ["/sbin/docker-entrypoint.sh"]
|
ENTRYPOINT ["/sbin/docker-entrypoint.sh"]
|
||||||
|
|
||||||
CMD ["--help"]
|
CMD ["--help"]
|
||||||
|
|
||||||
# Copy application
|
|
||||||
COPY src/ /usr/src/paperless/src/
|
|
||||||
COPY data/ /usr/src/paperless/data/
|
|
||||||
COPY media/ /usr/src/paperless/media/
|
|
||||||
|
|
||||||
# Collect static files
|
|
||||||
RUN sudo -HEu paperless /usr/src/paperless/src/manage.py collectstatic --clear --no-input
|
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
PAPERLESS_DBENGINE="django.db.backends.postgresql_psycopg2"
|
||||||
|
PAPERLESS_DBHOST="db"
|
||||||
|
PAPERLESS_DBNAME="paperless"
|
||||||
|
PAPERLESS_DBUSER="paperless"
|
||||||
|
PAPERLESS_DBPASS="paperless"
|
||||||
|
|
||||||
|
PAPERLESS_CONSUMPTION_DIR="../consume"
|
||||||
|
|
||||||
# Environment variables to set for Paperless
|
# Environment variables to set for Paperless
|
||||||
# Commented out variables will be replaced with a default within Paperless.
|
# Commented out variables will be replaced with a default within Paperless.
|
||||||
#
|
#
|
||||||
@ -5,24 +13,23 @@
|
|||||||
# paperless.conf.example here. Values like:
|
# paperless.conf.example here. Values like:
|
||||||
#
|
#
|
||||||
# * PAPERLESS_PASSPHRASE
|
# * PAPERLESS_PASSPHRASE
|
||||||
# * PAPERLESS_CONSUMPTION_DIR
|
|
||||||
# * PAPERLESS_CONSUME_MAIL_HOST
|
# * PAPERLESS_CONSUME_MAIL_HOST
|
||||||
#
|
#
|
||||||
# ...are all explained in that file but can be defined here, since the Docker
|
# ...are all explained in that file but can be defined here, since the Docker
|
||||||
# installation doesn't make use of paperless.conf.
|
# installation doesn't make use of paperless.conf.
|
||||||
|
|
||||||
# Use this variable to set a timezone for the Paperless Docker containers. If not specified, defaults to UTC.
|
# Use this variable to set a timezone for the Paperless Docker containers. If not specified, defaults to UTC.
|
||||||
# TZ=America/Los_Angeles
|
#TZ=America/Los_Angeles
|
||||||
|
|
||||||
# Additional languages to install for text recognition. Note that this is
|
# Additional languages to install for text recognition. Note that this is
|
||||||
# different from PAPERLESS_OCR_LANGUAGE (default=eng), which defines the
|
# different from PAPERLESS_OCR_LANGUAGE (default=eng), which defines the
|
||||||
# default language used when guessing the language from the OCR output.
|
# default language used when guessing the language from the OCR output.
|
||||||
# PAPERLESS_OCR_LANGUAGES=deu ita
|
# The container installs English, German, Italian, Spanish and French by
|
||||||
|
# default.
|
||||||
|
#PAPERLESS_OCR_LANGUAGES=deu ita spa fra
|
||||||
|
|
||||||
# Set Paperless to use SSL for the web interface.
|
# The UID and GID of the user used to run paperless in the container. Set this
|
||||||
# Enabling this will require ssl.key and ssl.cert files in paperless' data directory.
|
# to your UID and GID on the host so that you have write access to the
|
||||||
# PAPERLESS_USE_SSL=false
|
# consumption directory.
|
||||||
|
#USERMAP_UID=1000
|
||||||
# You can change the default user and group id to a custom one
|
#USERMAP_GID=1000
|
||||||
# USERMAP_UID=1000
|
|
||||||
# USERMAP_GID=1000
|
|
||||||
|
@ -1,56 +1,44 @@
|
|||||||
version: '2.1'
|
version: "3.8"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:13
|
||||||
|
#restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: paperless
|
||||||
|
POSTGRES_USER: paperless
|
||||||
|
POSTGRES_PASSWORD: paperless
|
||||||
|
|
||||||
webserver:
|
webserver:
|
||||||
build: ./
|
build: .
|
||||||
# uncomment the following line to start automatically on system boot
|
image: paperless_app
|
||||||
# restart: always
|
#restart: always
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
ports:
|
ports:
|
||||||
# You can adapt the port you want Paperless to listen on by
|
|
||||||
# modifying the part before the `:`.
|
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl" , "-f", "http://localhost:8000"]
|
test: ["CMD", "curl", "-f", "http://localhost:8000"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 5
|
retries: 5
|
||||||
volumes:
|
volumes:
|
||||||
- data:/usr/src/paperless/data
|
- data:/usr/src/paperless/data
|
||||||
- media:/usr/src/paperless/media
|
|
||||||
# You have to adapt the local path you want the consumption
|
|
||||||
# directory to mount to by modifying the part before the ':'.
|
|
||||||
- ./consume:/consume
|
|
||||||
env_file: docker-compose.env
|
env_file: docker-compose.env
|
||||||
# The reason the line is here is so that the webserver that doesn't do
|
|
||||||
# any text recognition and doesn't have to install unnecessary
|
|
||||||
# languages the user might have set in the env-file by overwriting the
|
|
||||||
# value with nothing.
|
|
||||||
environment:
|
environment:
|
||||||
- PAPERLESS_OCR_LANGUAGES=
|
- PAPERLESS_OCR_LANGUAGES=
|
||||||
command: ["gunicorn", "-b", "0.0.0.0:8000"]
|
command: ["gunicorn", "-b", "0.0.0.0:8000"]
|
||||||
|
|
||||||
consumer:
|
consumer:
|
||||||
build: ./
|
image: paperless_app
|
||||||
# uncomment the following line to start automatically on system boot
|
|
||||||
# restart: always
|
|
||||||
depends_on:
|
depends_on:
|
||||||
webserver:
|
- webserver
|
||||||
condition: service_healthy
|
- db
|
||||||
|
restart: on-failure:5
|
||||||
volumes:
|
volumes:
|
||||||
- data:/usr/src/paperless/data
|
- data:/usr/src/paperless/data
|
||||||
- media:/usr/src/paperless/media
|
- ./consume:/usr/src/paperless/consume
|
||||||
# This should be set to the same value as the consume directory
|
|
||||||
# in the webserver service above.
|
|
||||||
- ./consume:/consume
|
|
||||||
# Likewise, you can add a local path to mount a directory for
|
|
||||||
# exporting. This is not strictly needed for paperless to
|
|
||||||
# function, only if you're exporting your files: uncomment
|
|
||||||
# it and fill in a local path if you know you're going to
|
|
||||||
# want to export your documents.
|
|
||||||
# - /path/to/another/arbitrary/place:/export
|
|
||||||
env_file: docker-compose.env
|
env_file: docker-compose.env
|
||||||
command: ["document_consumer"]
|
command: ["document_consumer"]
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
data:
|
data:
|
||||||
media:
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Source: https://github.com/sameersbn/docker-gitlab/
|
# Source: https://github.com/sameersbn/docker-gitlab/
|
||||||
@ -14,34 +15,6 @@ map_uidgid() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
set_permissions() {
|
|
||||||
# Set permissions for consumption and export directory
|
|
||||||
for dir in PAPERLESS_CONSUMPTION_DIR PAPERLESS_EXPORT_DIR; do
|
|
||||||
# Extract the name of the current directory from $dir for the error message
|
|
||||||
cur_dir_name=$(echo "$dir" | awk -F'_' '{ print tolower($2); }')
|
|
||||||
chgrp paperless "${!dir}" || {
|
|
||||||
echo "Changing group of ${cur_dir_name} directory:"
|
|
||||||
echo " ${!dir}"
|
|
||||||
echo "failed."
|
|
||||||
echo ""
|
|
||||||
echo "Either try to set it on your host-mounted directory"
|
|
||||||
echo "directly, or make sure that the directory has \`g+wx\`"
|
|
||||||
echo "permissions and the files in it at least \`o+r\`."
|
|
||||||
} >&2
|
|
||||||
chmod g+wx "${!dir}" || {
|
|
||||||
echo "Changing group permissions of ${cur_dir_name} directory:"
|
|
||||||
echo " ${!dir}"
|
|
||||||
echo "failed."
|
|
||||||
echo ""
|
|
||||||
echo "Either try to set it on your host-mounted directory"
|
|
||||||
echo "directly, or make sure that the directory has \`g+wx\`"
|
|
||||||
echo "permissions and the files in it at least \`o+r\`."
|
|
||||||
} >&2
|
|
||||||
done
|
|
||||||
# Set permissions for application directory
|
|
||||||
chown -Rh paperless:paperless /usr/src/paperless
|
|
||||||
}
|
|
||||||
|
|
||||||
migrations() {
|
migrations() {
|
||||||
# A simple lock file in case other containers use this startup
|
# A simple lock file in case other containers use this startup
|
||||||
LOCKFILE="/usr/src/paperless/data/db.sqlite3.migration"
|
LOCKFILE="/usr/src/paperless/data/db.sqlite3.migration"
|
||||||
@ -50,18 +23,30 @@ migrations() {
|
|||||||
if (set -o noclobber; echo "$$" > "${LOCKFILE}") 2> /dev/null
|
if (set -o noclobber; echo "$$" > "${LOCKFILE}") 2> /dev/null
|
||||||
then
|
then
|
||||||
trap 'rm -f "${LOCKFILE}"; exit $?' INT TERM EXIT
|
trap 'rm -f "${LOCKFILE}"; exit $?' INT TERM EXIT
|
||||||
sudo -HEu paperless "/usr/src/paperless/src/manage.py" "migrate"
|
sudo -HEu paperless python3 manage.py migrate
|
||||||
rm ${LOCKFILE}
|
rm ${LOCKFILE}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
map_uidgid
|
map_uidgid
|
||||||
set_permissions
|
|
||||||
|
for data_dir in index media media/documents media/thumbnails; do
|
||||||
|
if [[ ! -d "../data/$data_dir" ]]
|
||||||
|
then
|
||||||
|
echo "creating directory ../data/$data_dir"
|
||||||
|
mkdir ../data/$data_dir
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
chown -R paperless:paperless ../
|
||||||
|
|
||||||
migrations
|
migrations
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_languages() {
|
install_languages() {
|
||||||
|
echo "TEST"
|
||||||
local langs="$1"
|
local langs="$1"
|
||||||
read -ra langs <<<"$langs"
|
read -ra langs <<<"$langs"
|
||||||
|
|
||||||
@ -69,28 +54,33 @@ install_languages() {
|
|||||||
if [ ${#langs[@]} -eq 0 ]; then
|
if [ ${#langs[@]} -eq 0 ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
apt-get update
|
||||||
|
|
||||||
# Loop over languages to be installed
|
|
||||||
for lang in "${langs[@]}"; do
|
for lang in "${langs[@]}"; do
|
||||||
pkg="tesseract-ocr-data-$lang"
|
pkg="tesseract-ocr-$lang"
|
||||||
|
|
||||||
# English is installed by default
|
# English is installed by default
|
||||||
if [[ "$lang" == "eng" ]]; then
|
#if [[ "$lang" == "eng" ]]; then
|
||||||
|
# continue
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if dpkg -s $pkg &> /dev/null; then
|
||||||
|
echo "package $pkg already installed!"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if apk info -e "$pkg" > /dev/null 2>&1; then
|
if ! apt-cache show $pkg &> /dev/null; then
|
||||||
continue
|
echo "package $pkg not found! :("
|
||||||
fi
|
|
||||||
if ! apk --no-cache info "$pkg" > /dev/null 2>&1; then
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apk --no-cache --update add "$pkg"
|
echo "Installing package $pkg..."
|
||||||
|
if ! apt-get -y install "$pkg" &> /dev/null; then
|
||||||
|
echo "Could not install $pkg"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [[ "$1" != "/"* ]]; then
|
if [[ "$1" != "/"* ]]; then
|
||||||
initialize
|
initialize
|
||||||
|
|
||||||
@ -101,21 +91,12 @@ if [[ "$1" != "/"* ]]; then
|
|||||||
|
|
||||||
if [[ "$1" = "gunicorn" ]]; then
|
if [[ "$1" = "gunicorn" ]]; then
|
||||||
shift
|
shift
|
||||||
EXTRA_PARAMS=""
|
|
||||||
SSL_KEY_PATH="/usr/src/paperless/data/ssl.key"
|
|
||||||
SSL_CERT_PATH="/usr/src/paperless/data/ssl.cert"
|
|
||||||
if [ "${PAPERLESS_USE_SSL}" = "true" ]; then
|
|
||||||
if [ -f "${SSL_KEY_PATH}" ] && [ -f "${SSL_CERT_PATH}" ]; then
|
|
||||||
EXTRA_PARAMS="--certfile=${SSL_CERT_PATH} --keyfile=${SSL_KEY_PATH}"
|
|
||||||
else
|
|
||||||
echo "Error: Could not find certfile in ${SSL_CERT_PATH} or keyfile in ${SSL_KEY_PATH}, but \$PAPERLESS_USE_SSL is true. Starting without SSL enabled."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
cd /usr/src/paperless/src/ && \
|
cd /usr/src/paperless/src/ && \
|
||||||
exec sudo -HEu paperless /usr/bin/gunicorn -c /usr/src/paperless/gunicorn.conf ${EXTRA_PARAMS} "$@" paperless.wsgi
|
exec sudo -HEu paperless gunicorn -c /usr/src/paperless/gunicorn.conf.py "$@" paperless.wsgi
|
||||||
else
|
|
||||||
exec sudo -HEu paperless "/usr/src/paperless/src/manage.py" "$@"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exec sudo -HEu paperless python3 manage.py "$@"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user