Deployment Overview of Paperless on Server¶
Prerequisites and Basic Requirements¶
The application requires a server running Ubuntu to function correctly. The following system requirements and dependencies must be met:
-
Operating System: Ubuntu
-
Privileges: Root or sudo access is required for installation.
-
System Dependencies:
-
Python 3 (including
python3-pip,python3-venv, andpython3-dev) -
Redis Server
-
OCR and Image Processing:
tesseract-ocr,tesseract-ocr-rus,imagemagick,ghostscript,unpaper -
PDF and File Utilities:
libpoppler-cpp-dev,libmagic-dev,mime-support -
Fonts:
fonts-liberation
FQDN of the final panel on the hostkey.in domain¶
The application is accessible via a specific subdomain template based on the server ID.
| Parameter | Value |
|---|---|
| Prefix | paperless-ngx |
| Domain | hostkey.in |
| Full template | paperless-ngx{Server_ID_from_Invapi}.hostkey.in |
File and Directory Structure¶
The application utilizes several specific directories for data persistence and configuration:
-
/opt/paperless: Main application directory. -
/opt/paperless/data: Application data storage. -
/opt/paperless/media: Media files storage. -
/opt/paperless/consume: Directory for incoming documents to be processed. -
/opt/paperless/export: Exported data directory. -
/root/nginx: Configuration and deployment files for the Nginx proxy. -
/data/nginx/user_conf.d: Custom Nginx user configurations.
Application installation process¶
The application is installed using a manual setup method involving source extraction and Python virtual environments:
-
System Setup: System dependencies are installed via
apt, and Redis is enabled and started as a system service. -
User Creation: A dedicated system user named
paperlessis created with the home directory/opt/paperless. -
Source Retrieval: The Paperless-ngx version
v2.20.15is downloaded from GitHub, extracted to/opt/paperless, and configured for thepaperlessuser. -
Dependency Management: A Python virtual environment (
.venv) is created within/opt/paperless. Specific database backends (likemysqlclientandpsycopg-c) are removed from the requirements list before installing dependencies viapip. -
Configuration: A
paperless.conffile is generated to define application settings, including time zone (Europe/Moscow), OCR languages (rus+eng), and Redis connection strings. -
Security Configuration: ImageMagick policy files are modified to allow the processing of PDF files.
-
Database Initialization: Database migrations are executed within the Python virtual environment.
-
Service Setup: Four systemd services are configured and enabled:
paperless-webserver,paperless-consumer,paperless-scheduler, andpaperless-task-queue.
Access Rights and Security¶
-
User Isolation: The application runs under a dedicated
paperlesssystem user to minimize security risks. -
File Permissions: Configuration files like
paperless.confare restricted with mode0640. -
Firewall/Proxy: An Nginx proxy handles external traffic, terminating SSL via Certbot.
Databases¶
The application uses Redis as a backend for task management and caching.
| Component | Connection Method | Storage Location |
|---|---|---|
| Redis | redis://localhost:6379 | System-managed (via redis-server) |
Docker Containers and Their Deployment¶
The deployment utilizes one primary container to manage SSL certificates and Nginx proxying.
Nginx Proxy Container
-
Image:
jonasal/nginx-certbot:latest -
Ports: 443 (External) / Host Network Mode
-
Volumes:
-
nginx_secrets:/etc/letsencrypt -
/data/nginx/user_conf.d:/etc/nginx/user_conf.d -
Environment Variables:
-
Restart Policy:
unless-stopped
Custom Scripts and Additional Setup¶
The installation performs several automated setup actions:
-
Superuser Creation: An administrative user (
root) is automatically created within the application using a provided environment variable for the password. -
Environment Configuration: The
paperless.conffile is dynamically populated with the correct FQDN based on the server's identity.
Application Update Instructions¶
To update the main Paperless-ngx application, follow these steps:
-
Download and extract the new version of the source code to
/opt/paperless. -
Re-run the Python dependency installation within the virtual environment:
-
Run database migrations:
-
Restart the services to apply changes:
Location of configuration files and data¶
| Type | Path |
|---|---|
| Main Configuration | /opt/paperless/paperless.conf |
| Application Data | /opt/paperless/data |
| Media Files | /opt/paperless/media |
| Consumption Folder | /opt/paperless/consume |
| Export Folder | /opt/paperless/export |
Available ports for connection¶
-
HTTPS:
443(via Nginx proxy) -
Internal Webserver:
3000(local access only) -
Redis:
6379(local access only)
Starting and Stopping the application¶
The application is managed via systemctl.
Starting all services:
sudo systemctl start paperless-webserver paperless-consumer paperless-scheduler paperless-task-queue
Stopping all services: