mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-26 03:36:08 -05:00
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`.
44 lines
1.2 KiB
Docker
44 lines
1.2 KiB
Docker
FROM python:3.5.1
|
|
MAINTAINER Pit Kleyersburg <pitkley@googlemail.com>
|
|
|
|
# Install dependencies
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
sudo \
|
|
tesseract-ocr tesseract-ocr-eng imagemagick ghostscript \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install python dependencies
|
|
RUN mkdir -p /usr/src/paperless
|
|
WORKDIR /usr/src/paperless
|
|
COPY requirements.txt /usr/src/paperless/
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application
|
|
RUN mkdir -p /usr/src/paperless/src
|
|
COPY src/ /usr/src/paperless/src/
|
|
|
|
# Set consumption directory
|
|
ENV PAPERLESS_CONSUME /consume
|
|
RUN mkdir -p $PAPERLESS_CONSUME
|
|
|
|
# Migrate database
|
|
WORKDIR /usr/src/paperless/src
|
|
RUN mkdir /usr/src/paperless/data
|
|
RUN ./manage.py migrate
|
|
|
|
# Create user
|
|
RUN groupadd -g 1000 paperless \
|
|
&& useradd -u 1000 -g 1000 -d /usr/src/paperless paperless \
|
|
&& chown -Rh paperless:paperless /usr/src/paperless
|
|
|
|
# Setup entrypoint
|
|
COPY scripts/docker-entrypoint.sh /sbin/docker-entrypoint.sh
|
|
RUN chmod 755 /sbin/docker-entrypoint.sh
|
|
|
|
# Mount volumes
|
|
VOLUME ["/usr/src/paperless/data", "/usr/src/paperless/media", "/consume"]
|
|
|
|
ENTRYPOINT ["/sbin/docker-entrypoint.sh"]
|
|
CMD ["--help"]
|