Menu

Docker Compose Production Template: PostgreSQL + Redis + Nginx + Backup
πŸ“°

Docker Compose Production Template: PostgreSQL + Redis + Nginx + Backup

DEV Community: postgresΒ·Riefqi DestiadyΒ·about 8 hours ago
#PRFon41g
#devtopostgresql#devto#dev#redis#docker
Reading 0:00
15s threshold

You have a hardened VPS (Article #1). Now you need a production-ready Docker Compose stack that you can drop in and run. This template gives you:

PostgreSQL with proper persistence, healthchecks, and backup

Redis for caching/sessions with persistence

Nginx reverse proxy with SSL termination (auto via Let's Encrypt)

Automated backup to local + optional S3 (Restic + Rclone)

Healthchecks on every service

Resource limits to prevent OOM kills

Log rotation so disk doesn't fill up

Prerequisites

VPS from Article #1 (Ubuntu 24.04, Docker + Compose, UFW, Fail2ban)

Domain pointed to VPS IP (for SSL)

SSH access as deploy user (non-root, in docker group)

Project Structure

/opt/app/ β”œβ”€β”€ docker-compose.yml β”œβ”€β”€ .env # Generated from .env.example β”œβ”€β”€ .env.example β”œβ”€β”€ nginx/ β”‚ β”œβ”€β”€ nginx.conf β”‚ β”œβ”€β”€ conf.d/ β”‚ β”‚ └── default.conf β”‚ └── certs/ # Let's Encrypt certs (auto-managed) β”œβ”€β”€ postgres/ β”‚ β”œβ”€β”€ init/ β”‚ β”‚ └── 01-init.sql β”‚ └── backup/ β”‚ └── backup.sh β”œβ”€β”€ redis/ β”‚ └── redis.conf β”œβ”€β”€ scripts/ β”‚ β”œβ”€β”€ deploy.sh β”‚ β”œβ”€β”€β€¦

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.