Deploying Docspell
Introduction
Docspell is a powerful open-source document management system (DMS) designed to help you organize, tag, and search through your documents efficiently. Built with Scala and Elm, Docspell provides automatic text recognition (OCR), full-text search, multi-user support, and intelligent tagging capabilities. Whether you’re managing personal documents, business records, or digital archives, Docspell offers a self-hosted solution that puts you in complete control of your data.
This comprehensive guide walks you through deploying Docspell on Klutch.sh using a Dockerfile. You’ll learn how to set up persistent storage for your documents and database, configure environment variables for secure operation, and implement best practices for a production-ready deployment. Klutch.sh automatically detects your Dockerfile and builds your application, making deployment seamless and efficient.
By the end of this guide, you’ll have a fully functional Docspell instance running on Klutch.sh, ready to handle your document management needs with automatic backups, scalable infrastructure, and secure document storage.
What You’ll Need
Before starting this deployment, ensure you have:
- A Klutch.sh account - sign up here if you don’t have one
- A GitHub repository for your Docspell deployment
- Basic understanding of Docker and containerization concepts
- PostgreSQL database (recommended) or H2 database for smaller deployments
- Basic knowledge of document management systems and web applications
Understanding Docspell Architecture
Docspell consists of two main components:
- REST Server - The backend API that handles document processing, OCR, database operations, and business logic
- Joex - The job executor that processes documents asynchronously, performing OCR, text extraction, and metadata extraction
For a complete deployment, you’ll need to run both components. This guide focuses on deploying the all-in-one Docker image that includes both services, simplifying the deployment process on Klutch.sh.
Step 1: Setting Up Your GitHub Repository
-
Create a new GitHub repository or use an existing one for your Docspell deployment:
Terminal window mkdir docspell-deploycd docspell-deploygit init -
Create a
.gitignorefile to exclude sensitive files:# Environment files.env.env.local# Data directoriesdata/logs/# Dockerdocker-compose.ymlNote: Docker Compose is not supported by Klutch.sh for deployment, but you can use it for local development if needed.
-
Commit and push your initial repository structure to GitHub:
Terminal window git add .git commit -m "Initial Docspell repository setup"git remote add origin https://github.com/YOUR_USERNAME/docspell-deploy.gitgit push -u origin main
For detailed instructions on connecting your GitHub repository to Klutch.sh, refer to the Quick Start Guide.
Step 2: Creating the Dockerfile
Create a Dockerfile in the root of your repository. Klutch.sh will automatically detect this Dockerfile when you deploy your application.
Here’s a production-ready Dockerfile for Docspell:
# Use the official Docspell all-in-one image with a specific versionFROM eikek0/docspell:v0.41.0
# Set working directoryWORKDIR /opt/docspell
# Create directories for persistent dataRUN mkdir -p /opt/docspell/data && \ mkdir -p /opt/docspell/config
# Expose the default Docspell portEXPOSE 7880
# The default entrypoint starts both REST server and Joex components# No CMD needed - use the image's default entrypointAdvanced Dockerfile with Custom Configuration
For more control over your deployment, you can create a custom Dockerfile with additional configuration:
FROM eikek0/docspell:v0.41.0
WORKDIR /opt/docspell
# Install additional tools for health checks and OCR languagesRUN apt-get update && \ apt-get install -y --no-install-recommends \ curl \ ca-certificates \ tesseract-ocr \ tesseract-ocr-eng \ tesseract-ocr-deu && \ rm -rf /var/lib/apt/lists/*
# Create necessary directoriesRUN mkdir -p /opt/docspell/data \ /opt/docspell/config \ /opt/docspell/logs
# Copy custom configuration if you have one# COPY ./config/docspell.conf /opt/docspell/config/
# Optional: Health check (requires curl installed above)HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7880/api/info/version || exit 1
EXPOSE 7880
# Use the default entrypoint from the base imageStep 3: Configuring Environment Variables
Docspell requires several environment variables for proper operation. These should be configured in the Klutch.sh dashboard under your app’s environment variables section.
Required Environment Variables
# Database ConfigurationDOCSPELL_DB_TYPE=postgresqlDOCSPELL_DB_HOST=your-postgres-hostDOCSPELL_DB_PORT=5432DOCSPELL_DB_NAME=docspellDOCSPELL_DB_USER=docspell_userDOCSPELL_DB_PASSWORD=your-secure-password
# Server ConfigurationDOCSPELL_BASE_URL=https://example-app.klutch.shDOCSPELL_BIND_ADDRESS=0.0.0.0DOCSPELL_BIND_PORT=7880
# SecurityDOCSPELL_SERVER_SECRET=your-random-secret-key-min-64-charsOptional Environment Variables
# OCR ConfigurationDOCSPELL_OCR_ENABLED=trueDOCSPELL_OCR_LANGUAGES=eng,deu
# File StorageDOCSPELL_FILES_CHUNK_SIZE=524288
# Admin Account (First-time setup - CHANGE THESE IMMEDIATELY!)DOCSPELL_ADMIN_USER=adminDOCSPELL_ADMIN_PASSWORD=change-this-secure-password-immediately
# LoggingDOCSPELL_LOG_LEVEL=InfoSecurity Warning: The admin password shown above is just an example. You must change this to a strong, unique password immediately after first login. Never use simple passwords like “admin” in production.
Using Nixpacks Build/Runtime Environment Variables
If you need to customize the build or start command using Nixpacks, you can set these environment variables:
# Custom start commandNIXPACKS_START_CMD=/opt/docspell/docspell-restserver
# Build-time environment variablesNIXPACKS_BUILD_ENV=NODE_ENV=productionImportant: Store all sensitive values (database passwords, secret keys) as environment variables in Klutch.sh. Never commit these to your repository. Use the Klutch.sh dashboard at klutch.sh/app to securely manage environment variables.
Step 4: Setting Up Persistent Storage
Docspell requires persistent storage to maintain your documents, database files, and configuration across deployments.
-
Navigate to your app in the Klutch.sh dashboard at klutch.sh/app
-
Go to the Volumes section of your app
-
Create a volume for document storage:
- Mount Path:
/opt/docspell/data - Size: Minimum 10GB (adjust based on your document volume)
- Mount Path:
-
Create a volume for configuration:
- Mount Path:
/opt/docspell/config - Size: 1GB
- Mount Path:
-
(Optional) Create a volume for logs:
- Mount Path:
/opt/docspell/logs - Size: 5GB
- Mount Path:
Note: Klutch.sh volumes only require you to specify the mount path and size. The volume names are managed automatically by the platform.
Volume Structure
Your persistent volumes should follow this structure:
/opt/docspell/data/ # Uploaded documents and processed files/opt/docspell/config/ # Configuration files/opt/docspell/logs/ # Application logsFor more details on managing volumes, see the Volumes Guide.
Step 5: Deploying to Klutch.sh
Now that you have your Dockerfile and configuration ready, let’s deploy Docspell to Klutch.sh.
-
Push your code to GitHub:
Terminal window git add Dockerfilegit commit -m "Add Docspell Dockerfile"git push origin main -
Create a new app in Klutch.sh:
- Log in to klutch.sh/app
- Click New App or Create Project
- Select your GitHub repository
-
Configure your app:
- App Name:
docspell(or your preferred name) - Branch:
main(or your default branch) - Klutch.sh will automatically detect your Dockerfile in the root directory
- App Name:
-
Configure traffic settings:
- Select HTTP traffic type (Docspell is a web application)
- Set the internal port to 7880 (Docspell’s default port)
-
Add environment variables:
- Add all the environment variables from Step 3
- Mark sensitive variables (passwords, secrets) as secret
-
Attach persistent volumes:
- Add the volumes you configured in Step 4
- Verify the mount paths are correct
-
Deploy:
- Click Deploy or Create
- Klutch.sh will build your Docker image and deploy your application
Your Docspell instance will be available at https://example-app.klutch.sh (replace with your actual app URL).
Step 6: Setting Up the Database
Docspell requires a database to store metadata, user information, and document indexes. While H2 (embedded database) works for testing, PostgreSQL is recommended for production.
Option A: Using PostgreSQL (Recommended)
-
Create a PostgreSQL database on Klutch.sh or use an external provider
-
Set the following environment variables in your Klutch.sh app:
Terminal window DOCSPELL_DB_TYPE=postgresqlDOCSPELL_DB_HOST=your-postgres-hostDOCSPELL_DB_PORT=5432DOCSPELL_DB_NAME=docspellDOCSPELL_DB_USER=docspell_userDOCSPELL_DB_PASSWORD=your-secure-password -
Docspell will automatically create the necessary tables on first startup
Option B: Using H2 Database (Testing Only)
For quick testing or development, you can use the embedded H2 database:
DOCSPELL_DB_TYPE=h2DOCSPELL_DB_PATH=/opt/docspell/data/docspell.dbWarning: H2 is not recommended for production use due to performance limitations and lack of concurrent access support.
Step 7: Initial Configuration
After your first deployment, you’ll need to complete the initial setup:
-
Access Docspell: Navigate to your app URL (e.g.,
https://example-app.klutch.sh) -
Create the first user:
- If you set
DOCSPELL_ADMIN_USERandDOCSPELL_ADMIN_PASSWORD, log in with those credentials - Otherwise, register a new user through the web interface
- If you set
-
Configure OCR languages:
- Go to Settings → Processing
- Select the languages you need for OCR (English, German, etc.)
-
Set up integrations (optional):
- Email integration for document import
- Scanner integration
- Mobile app connection
-
Test document upload:
- Upload a test document
- Verify OCR processing works
- Check that documents are stored in your persistent volume
Advanced Configuration
Custom Configuration File
If you need more control over Docspell’s configuration, create a custom configuration file:
docspell { server { bind { address = "0.0.0.0" port = 7880 }
base-url = "https://example-app.klutch.sh"
backend { jdbc { url = "jdbc:postgresql://${DOCSPELL_DB_HOST}:${DOCSPELL_DB_PORT}/${DOCSPELL_DB_NAME}" user = ${DOCSPELL_DB_USER} password = ${DOCSPELL_DB_PASSWORD} }
signup { mode = "invite" }
files { chunk-size = 524288 } } }
joex { bind { address = "0.0.0.0" port = 7878 }
scheduler { pool-size = 2 } }}Mount this configuration file using a persistent volume or include it in your Docker image.
Email Integration
To enable email-based document import:
# Environment variables for email integrationDOCSPELL_IMAP_ENABLED=trueDOCSPELL_IMAP_HOST=imap.gmail.comDOCSPELL_IMAP_PORT=993DOCSPELL_IMAP_USER=your-email@gmail.comDOCSPELL_IMAP_PASSWORD=your-app-passwordDOCSPELL_IMAP_SSL=trueScaling Considerations
For high-volume document processing:
- Increase Joex pool size: Set
DOCSPELL_JOEX_POOL_SIZEto a higher value - Add more memory: Allocate at least 2GB RAM for OCR-heavy workloads
- Use external object storage: Configure S3-compatible storage for documents
- Separate Joex workers: Deploy additional Joex instances for parallel processing
Monitoring and Maintenance
Health Checks
Docspell includes a health check endpoint at /api/info/version. Monitor this endpoint to ensure your application is running correctly.
Logs
Access application logs through the Klutch.sh dashboard or by mounting a logs volume:
# View logs in Klutch.sh dashboard# Or mount a volume to /opt/docspell/logsBackups
Critical: Regularly backup your persistent volumes and database:
-
Database backups:
Terminal window pg_dump -h your-host -U docspell_user docspell > backup-$(date +%Y%m%d).sql -
Document backups: Backup the
/opt/docspell/datavolume regularly -
Configuration backups: Keep your environment variables and configuration files in a secure location
Updates
To update Docspell to a new version:
-
Update the Docker image version in your Dockerfile:
FROM eikek0/docspell:v0.41.0 -
Commit and push the changes:
Terminal window git add Dockerfilegit commit -m "Update Docspell to v0.41.0"git push origin main -
Klutch.sh will automatically rebuild and redeploy your application
Troubleshooting
Common Issues
Application won’t start:
- Check environment variables are set correctly
- Verify database connection settings
- Ensure persistent volumes are mounted correctly
- Check logs in the Klutch.sh dashboard
OCR not working:
- Verify Tesseract is installed in your Docker image
- Check
DOCSPELL_OCR_ENABLED=trueis set - Ensure sufficient memory is allocated (minimum 1GB)
Database connection errors:
- Verify database host, port, username, and password
- Check network connectivity between app and database
- Ensure database exists and is accessible
File upload failures:
- Check persistent volume has sufficient space
- Verify file permissions on mounted volumes
- Check
DOCSPELL_FILES_CHUNK_SIZEsetting
Performance Optimization
- Increase memory allocation: OCR processing is memory-intensive
- Use PostgreSQL: Much faster than H2 for production workloads
- Adjust chunk size: Increase
DOCSPELL_FILES_CHUNK_SIZEfor larger files - Enable caching: Configure Redis for session caching
- Optimize database: Regular vacuum and analyze operations
Security Best Practices
- Use strong passwords: Generate secure passwords for database and admin accounts
- Enable HTTPS: Klutch.sh provides automatic HTTPS for all deployments
- Restrict signup mode: Set
signup.mode = "invite"for production - Regular updates: Keep Docspell and dependencies updated
- Backup encryption: Encrypt backups of sensitive documents
- Environment variables: Never commit secrets to your repository
- Access control: Use Docspell’s built-in user management and permissions
Next Steps
Now that you have Docspell running on Klutch.sh, consider these next steps:
- Configure email integration for automatic document import
- Set up mobile app access for on-the-go document scanning
- Integrate with your existing document workflows
- Configure automatic tagging and classification rules
- Set up scheduled backups for your documents and database
- Explore Docspell’s API for custom integrations
Resources
- Official Docspell Documentation
- Docspell GitHub Repository
- Klutch.sh Quick Start Guide
- Klutch.sh Volumes Guide
- Klutch.sh Builds Guide
- Klutch.sh Deployments Guide
Deploying Docspell on Klutch.sh gives you a powerful, self-hosted document management solution with automatic builds, persistent storage, and scalable infrastructure. With this guide, you’re equipped to manage documents efficiently while maintaining full control over your data. For questions or support, visit the Klutch.sh community or consult the official Docspell documentation.