docker.recipes

Papermerge

intermediate

Document management system with OCR.

Overview

Papermerge is an open-source document management system designed to transform paper-based workflows into digital, searchable archives. Built with Django, it provides OCR capabilities to automatically extract text from scanned documents, PDFs, and images, making them fully searchable and organizable through tags, metadata, and folder structures. The system excels at handling invoices, receipts, contracts, and other business documents that need long-term storage and quick retrieval. This stack combines Papermerge with PostgreSQL and Redis to create a robust document processing pipeline. PostgreSQL serves as the primary database, storing document metadata, user information, and OCR-extracted text with full-text search capabilities. Redis handles background job queuing for OCR processing, caching frequently accessed data, and managing user sessions. When documents are uploaded, Redis queues OCR tasks while PostgreSQL indexes the extracted text for lightning-fast searches across thousands of documents. Small businesses, accounting firms, legal offices, and home users will find this combination ideal for going paperless. The PostgreSQL backend ensures document metadata integrity and supports complex searches across multiple fields, while Redis accelerates the OCR workflow and improves response times. This setup scales from personal document archives to business-grade document repositories handling thousands of files monthly.

Key Features

  • Tesseract OCR engine integration for automatic text extraction from scanned PDFs and images
  • PostgreSQL full-text search with ranking across document content and metadata
  • Redis-powered background job processing for non-blocking OCR operations
  • Document versioning and audit trails stored in PostgreSQL with ACID compliance
  • Multi-format support including PDF, TIFF, PNG, and JPEG with OCR preprocessing
  • Tag-based organization with PostgreSQL foreign key relationships for data integrity
  • User permission system with role-based access control backed by PostgreSQL
  • Watched folder functionality for automatic document ingestion and OCR processing

Common Use Cases

  • 1Small business invoice and receipt digitization with automated OCR processing
  • 2Legal document archives requiring full-text search across case files and contracts
  • 3Accounting firm client document management with secure multi-tenant access
  • 4Home office paperless workflow for tax documents, warranties, and personal records
  • 5Medical practice patient file digitization with HIPAA-compliant document storage
  • 6Real estate agencies organizing property documents, contracts, and inspection reports
  • 7HR departments managing employee records, contracts, and compliance documentation

Prerequisites

  • Minimum 2GB RAM (1GB+ for PostgreSQL, 512MB+ for Redis, 512MB+ for Papermerge OCR processing)
  • Docker and Docker Compose installed with container runtime support
  • Port 12000 available for Papermerge web interface access
  • Basic understanding of environment variables and password management
  • At least 10GB free disk space for document storage and PostgreSQL data
  • Knowledge of PostgreSQL administration for database maintenance and backups

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 papermerge:
3 image: papermerge/papermerge:latest
4 container_name: papermerge
5 restart: unless-stopped
6 environment:
7 PAPERMERGE__SECURITY__SECRET_KEY: ${SECRET_KEY}
8 PAPERMERGE__DATABASE__URL: postgresql://papermerge:${DB_PASSWORD}@postgres:5432/papermerge
9 PAPERMERGE__REDIS__URL: redis://redis:6379/0
10 DJANGO_SUPERUSER_USERNAME: admin
11 DJANGO_SUPERUSER_PASSWORD: ${ADMIN_PASSWORD}
12 volumes:
13 - papermerge_media:/app/media
14 ports:
15 - "12000:80"
16 depends_on:
17 - postgres
18 - redis
19 networks:
20 - papermerge
21
22 postgres:
23 image: postgres:15-alpine
24 container_name: papermerge-postgres
25 restart: unless-stopped
26 environment:
27 POSTGRES_USER: papermerge
28 POSTGRES_PASSWORD: ${DB_PASSWORD}
29 POSTGRES_DB: papermerge
30 volumes:
31 - postgres_data:/var/lib/postgresql/data
32 networks:
33 - papermerge
34
35 redis:
36 image: redis:alpine
37 container_name: papermerge-redis
38 restart: unless-stopped
39 networks:
40 - papermerge
41
42volumes:
43 papermerge_media:
44 postgres_data:
45
46networks:
47 papermerge:
48 driver: bridge

.env Template

.env
1SECRET_KEY=changeme-secret-key
2DB_PASSWORD=changeme
3ADMIN_PASSWORD=changeme

Usage Notes

  1. 1Docs: https://docs.papermerge.io/
  2. 2Access at http://localhost:12000 - login with admin / ADMIN_PASSWORD
  3. 3OCR extracts text from scanned PDFs automatically
  4. 4Upload PDFs via web UI or watched folders
  5. 5Tagging, metadata, full-text search
  6. 6Good for digitizing paper documents, invoices, receipts

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

papermerge
papermerge:
  image: papermerge/papermerge:latest
  container_name: papermerge
  restart: unless-stopped
  environment:
    PAPERMERGE__SECURITY__SECRET_KEY: ${SECRET_KEY}
    PAPERMERGE__DATABASE__URL: postgresql://papermerge:${DB_PASSWORD}@postgres:5432/papermerge
    PAPERMERGE__REDIS__URL: redis://redis:6379/0
    DJANGO_SUPERUSER_USERNAME: admin
    DJANGO_SUPERUSER_PASSWORD: ${ADMIN_PASSWORD}
  volumes:
    - papermerge_media:/app/media
  ports:
    - "12000:80"
  depends_on:
    - postgres
    - redis
  networks:
    - papermerge
postgres
postgres:
  image: postgres:15-alpine
  container_name: papermerge-postgres
  restart: unless-stopped
  environment:
    POSTGRES_USER: papermerge
    POSTGRES_PASSWORD: ${DB_PASSWORD}
    POSTGRES_DB: papermerge
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - papermerge
redis
redis:
  image: redis:alpine
  container_name: papermerge-redis
  restart: unless-stopped
  networks:
    - papermerge

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 papermerge:
5 image: papermerge/papermerge:latest
6 container_name: papermerge
7 restart: unless-stopped
8 environment:
9 PAPERMERGE__SECURITY__SECRET_KEY: ${SECRET_KEY}
10 PAPERMERGE__DATABASE__URL: postgresql://papermerge:${DB_PASSWORD}@postgres:5432/papermerge
11 PAPERMERGE__REDIS__URL: redis://redis:6379/0
12 DJANGO_SUPERUSER_USERNAME: admin
13 DJANGO_SUPERUSER_PASSWORD: ${ADMIN_PASSWORD}
14 volumes:
15 - papermerge_media:/app/media
16 ports:
17 - "12000:80"
18 depends_on:
19 - postgres
20 - redis
21 networks:
22 - papermerge
23
24 postgres:
25 image: postgres:15-alpine
26 container_name: papermerge-postgres
27 restart: unless-stopped
28 environment:
29 POSTGRES_USER: papermerge
30 POSTGRES_PASSWORD: ${DB_PASSWORD}
31 POSTGRES_DB: papermerge
32 volumes:
33 - postgres_data:/var/lib/postgresql/data
34 networks:
35 - papermerge
36
37 redis:
38 image: redis:alpine
39 container_name: papermerge-redis
40 restart: unless-stopped
41 networks:
42 - papermerge
43
44volumes:
45 papermerge_media:
46 postgres_data:
47
48networks:
49 papermerge:
50 driver: bridge
51EOF
52
53# 2. Create the .env file
54cat > .env << 'EOF'
55SECRET_KEY=changeme-secret-key
56DB_PASSWORD=changeme
57ADMIN_PASSWORD=changeme
58EOF
59
60# 3. Start the services
61docker compose up -d
62
63# 4. View logs
64docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/papermerge/run | bash

Troubleshooting

  • OCR processing fails silently: Check Redis connectivity and ensure sufficient memory allocation for Tesseract processing
  • Document uploads timeout on large files: Increase Django file upload limits and Redis memory configuration in environment variables
  • PostgreSQL connection refused errors: Verify database initialization completed and check POSTGRES_PASSWORD matches PAPERMERGE__DATABASE__URL credentials
  • Search results incomplete or missing: Run Django management commands to rebuild PostgreSQL full-text search indexes
  • Redis memory usage grows continuously: Configure Redis maxmemory policy and enable key expiration for cached OCR results
  • Papermerge container fails to start: Ensure SECRET_KEY environment variable is set and database migration completed successfully

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space