paperless-ngx/Dockerfile

87 lines
2.6 KiB
Text
Raw Normal View History

2020-10-29 00:46:57 +01:00
###############################################################################
### Front end ###
###############################################################################
2020-10-29 00:46:57 +01:00
FROM node:current AS frontend
WORKDIR /usr/src/paperless/src-ui/
COPY src-ui/package* ./
RUN npm install
COPY src-ui .
2020-10-29 22:30:36 +01:00
RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false
2020-10-29 00:46:57 +01:00
###############################################################################
### Back end ###
###############################################################################
2020-11-05 11:23:58 +01:00
FROM ubuntu:20.04
2020-10-29 00:46:57 +01:00
WORKDIR /usr/src/paperless/
COPY Pipfile* ./
#Dependencies
RUN apt-get update \
2020-11-05 11:23:58 +01:00
&& DEBIAN_FRONTEND="noninteractive" apt-get -y --no-install-recommends install \
2020-11-01 23:01:36 +01:00
anacron \
2020-10-29 00:46:57 +01:00
build-essential \
curl \
ghostscript \
gnupg \
imagemagick \
libmagic-dev \
libpoppler-cpp-dev \
libpq-dev \
optipng \
2020-11-05 11:23:58 +01:00
python3 \
python3-dev \
python3-pip \
2020-10-29 00:46:57 +01:00
sudo \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-deu \
tesseract-ocr-fra \
tesseract-ocr-ita \
tesseract-ocr-spa \
tzdata \
unpaper \
2020-11-05 11:23:58 +01:00
&& pip3 install --upgrade pipenv supervisor setuptools \
2020-10-29 00:46:57 +01:00
&& pipenv install --system --deploy \
&& pipenv --clear \
2020-11-05 11:23:58 +01:00
&& apt-get -y purge build-essential python3-pip python3-dev \
2020-10-29 00:46:57 +01:00
&& apt-get -y autoremove --purge \
2020-11-01 23:01:36 +01:00
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /var/log/supervisord /var/run/supervisord
2020-10-29 00:46:57 +01:00
2020-11-01 23:01:36 +01:00
# copy scripts
# this fixes issues with imagemagick and PDF
COPY scripts/imagemagick-policy.xml /etc/ImageMagick-6/policy.xml
2020-10-29 00:46:57 +01:00
COPY scripts/gunicorn.conf.py ./
2020-11-01 23:01:36 +01:00
COPY scripts/supervisord.conf /etc/supervisord.conf
COPY scripts/paperless-cron /etc/cron.daily/
COPY scripts/docker-entrypoint.sh /sbin/docker-entrypoint.sh
# copy app
2020-10-29 00:46:57 +01:00
COPY src/ ./src/
COPY --from=frontend /usr/src/paperless/src-ui/dist/paperless-ui/ ./src/documents/static/frontend/
2020-10-29 00:46:57 +01:00
2020-11-01 23:01:36 +01:00
# add users, setup scripts
RUN addgroup --gid 1000 paperless \
&& useradd --uid 1000 --gid paperless --home-dir /usr/src/paperless paperless \
&& chown -R paperless:paperless . \
&& chmod 755 /sbin/docker-entrypoint.sh \
&& chmod +x /etc/cron.daily/paperless-cron \
&& rm /etc/cron.daily/apt-compat /etc/cron.daily/dpkg
2020-10-29 00:46:57 +01:00
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"]
Add Dockerfile for application and documentation This commit adds a `Dockerfile` to the root of the project, accompanied by a `docker-compose.yml.example` for simplified deployment. The `Dockerfile` is agnostic to whether it will be the webserver, the consumer, or if it is run for a one-off command (i.e. creation of a superuser, migration of the database, document export, ...). The containers entrypoint is the `scripts/docker-entrypoint.sh` script. This script verifies that the required permissions are set, remaps the default users and/or groups id if required and installs additional languages if the user wishes to. After initialization, it analyzes the command the user supplied: - If the command starts with a slash, it is expected that the user wants to execute a binary file and the command will be executed without further intervention. (Using `exec` to effectively replace the started shell-script and not have any reaping-issues.) - If the command does not start with a slash, the command will be passed directly to the `manage.py` script without further modification. (Again using `exec`.) The default command is set to `--help`. If the user wants to execute a command that is not meant for `manage.py` but doesn't start with a slash, the Docker `--entrypoint` parameter can be used to circumvent the mechanics of `docker-entrypoint.sh`. Further information can be found in `docs/setup.rst` and in `docs/migrating.rst`. For additional convenience, a `Dockerfile` has been added to the `docs/` directory which allows for easy building and serving of the documentation. This is documented in `docs/requirements.rst`.
2016-02-17 18:45:04 +01:00
ENTRYPOINT ["/sbin/docker-entrypoint.sh"]
2020-11-01 23:01:36 +01:00
CMD ["python3", "manage.py", "--help"]
2020-11-04 20:09:35 +01:00
LABEL maintainer="Jonas Winkler <dev@jpwinkler.de>"