Production-grade Docker Compose setup for a full-stack app. App, DB, Redis, worker, nginx — with hot reload, health checks, and named volumes.
## Task
Complete Docker Compose development environment for a full-stack application.
## Requirements
- Services: App (Next.js), PostgreSQL, Redis, Background Worker, Nginx
- Hot reload for development
- Health checks on all services
- Named volumes for data persistence
## docker-compose.yml
```yaml
# Generate a production-grade docker-compose.yml with:
services:
app:
# Next.js with hot reload (bind mount src/)
# Health check: curl localhost:3000/api/health
# Depends on: db, redis
# Environment from .env file
db:
# PostgreSQL 16 with named volume
# Health check: pg_isready
# Custom postgresql.conf for dev (more logging)
# Init script in /docker-entrypoint-initdb.d/
redis:
# Redis 7 with persistence (AOF)
# Health check: redis-cli ping
# Max memory policy: allkeys-lru
worker:
# Same image as app, different command
# Runs: node worker.js
# Depends on: db, redis
# Restart: unless-stopped
nginx:
# Reverse proxy with SSL termination (self-signed for dev)
# Rate limiting
# Gzip compression
# Static file caching headers
```
## Implementation Notes
1. Use multi-stage Dockerfile: dev (with devDependencies) and prod (optimized)
2. .dockerignore: node_modules, .next, .git, .env
3. Bind mount only src/ for hot reload (not node_modules)
4. Use `depends_on` with `condition: service_healthy` — not just service_started
5. Network: create internal network, only expose nginx ports externally
6. Makefile with shortcuts: make up, make down, make logs, make shellNo gallery images yet.