etsy-finance-tracker/docker-compose.yml
dlawler489 b2da6c69ed Add Nginx reverse proxy for production deployment
Architecture Updates:
- Nginx serves static React files for optimal performance
- Nginx proxies API requests to Node.js backend (port 8080)
- Separation of concerns: static files vs API handling
- Professional production setup with proper caching

Features Added:
- nginx.conf with optimized configuration:
  - Static file serving with long-term caching
  - API reverse proxy with rate limiting
  - Security headers and GZIP compression
  - Health check proxying and SPA routing support
- Updated docker-compose.yml for multi-container setup
- build-deploy.sh script for automated deployment
- Updated environment configuration for container networking

Security & Performance:
- Rate limiting on API and auth endpoints
- Security headers (XSS, CSRF, clickjacking protection)
- GZIP compression for static assets
- Proper cache control headers
- Container-to-container communication

Deployment:
- Single command deployment with ./build-deploy.sh
- Nginx on port 80 (exposed as 3000) serving React app
- API server on internal port 8080 (not exposed)
- Persistent data volume mounting for business files
2026-04-21 06:30:44 +10:00

73 lines
No EOL
1.7 KiB
YAML

version: '3.8'
services:
# Nginx reverse proxy and static file server
nginx:
image: nginx:alpine
container_name: etsy-nginx
ports:
- "3000:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./client/dist:/usr/share/nginx/html:ro
depends_on:
- etsy-tracker
restart: unless-stopped
networks:
- etsy-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# Etsy Finance Tracker API Server
etsy-tracker:
build:
context: .
dockerfile: Dockerfile
container_name: etsy-finance-tracker
expose:
- "8080"
environment:
- NODE_ENV=production
- PORT=8080
- CLIENT_URL=http://nginx
volumes:
# Mount data directory for persistent storage
- ./data:/app/data
# Optional: Mount uploads directory if needed
- etsy_uploads:/app/uploads
restart: unless-stopped
networks:
- etsy-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Optional: MongoDB for future database needs
# mongodb:
# image: mongo:6.0
# container_name: etsy-mongo
# ports:
# - "27017:27017"
# environment:
# MONGO_INITDB_ROOT_USERNAME: admin
# MONGO_INITDB_ROOT_PASSWORD: changeme
# volumes:
# - etsy_mongodb_data:/data/db
# networks:
# - etsy-network
# restart: unless-stopped
volumes:
etsy_uploads:
# etsy_mongodb_data:
networks:
etsy-network:
driver: bridge