This repository contains a production-ready template for deploying n8n — the powerful workflow automation tool — in a secure, scalable, and extensible environment without the need for the Enterprise license.
It supports:
- Scalable worker-based execution using Redis queues
- Secure PostgreSQL storage
- Automated backups
- Clean environment separation (production, staging, internal)
- Optional domain-based configuration with HTTPS
- Full customization for real-world, team-based use cases
n8n: Main web interface, configured securely with basic authentication and HTTPS support.n8n-worker: Headless execution container usingEXECUTIONS_MODE=queue.redis: Used for queue-based execution management.postgres: Stores workflows, credentials, and execution logs.volumes: Persistent storage for DB and n8n internal data.
The deployment uses an x-shared block in docker-compose.yml to:
- Avoid duplication across services
- Ensure consistent environment variables
- Keep the configuration DRY and clean
├── docker-compose.yml # Main multi-service deployment
├── .env # Environment variables (not committed)
├── .env.production.example # Example file for secure deployments
├── scripts/
│ └── backup.sh # Optional: cron-compatible backup script
└── README.md # You're here!
git clone https://github.com/your-org/n8n-deploy-template.git
cd n8n-deploy-templatecp .env.production.example .envEdit the file and fill in secure values for your database, domain, and encryption key.
The deployment will default to
localhostifN8N_DOMAINis not provided.
docker compose up -dYou can configure your deployment for a custom domain:
N8N_DOMAIN=n8n.yourdomain.com
N8N_PROTOCOL=httpsIf these values are omitted, the system will default to localhost for development.
You can scale execution by adding more n8n-worker services:
n8n-worker-2:
<<: *shared
command: worker
n8n-worker-3:
<<: *shared
command: workerWorkers will auto-discover tasks via Redis queues and run them in parallel.
- 🔑
ENCRYPTION_KEYfor data protection (required in production) - 🔐 Basic auth enabled by default
- 🔒 No ports exposed publicly except for
n8n - 🧱 Optional reverse proxy support (e.g., Traefik, Nginx)
- 🌩️ Cloudflare integration recommended for production
Backups can be made using a simple cron-compatible script like this:
docker exec n8n tar czf /backups/n8n-$(date +%F).tar.gz /home/node/.n8nYou can also export workflows and credentials directly via n8n and upload them to S3, email, or another backup destination.
- 🔍 Logs available via
docker logs n8n - 🧭 Integrate Prometheus + Grafana + Loki for metrics and logging
- Monitor queue execution, failed jobs, execution time, etc.
- Each environment (production, test, internal) can use its own
.envfile and DB instance. - You can customize the n8n UI by injecting branding via Dockerfile overrides (optional).
- A GitHub Actions workflow can automate deployment to platforms like Dokploy or Railway.
ENCRYPTION_KEY=REPLACE_WITH_SECURE_KEY
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=REPLACE_WITH_SECURE_PASSWORD
POSTGRES_USER=n8n
POSTGRES_PASSWORD=REPLACE_WITH_SECURE_DB_PASSWORD
POSTGRES_DB=n8n
N8N_DOMAIN=n8n.example.com
N8N_PROTOCOL=httpsMIT or custom license depending on your organization needs.
Template created and maintained by Franblakia for BlakIA.
Powered by n8n, PostgreSQL, Redis and Docker Compose.