Files
metabuilder/deployment/docker-compose.production.yml
copilot-swe-agent[bot] 5c0fc0b794 Add fire-and-forget Docker deployment for entire project
Created comprehensive production and development deployment configurations in `/deployment` folder:

**Production Stack (docker-compose.production.yml):**
- PostgreSQL 16 with persistent storage
- C++ DBAL Daemon (optimized, daemon mode)
- MetaBuilder App (production build)
- Nginx reverse proxy with SSL/TLS
- Redis cache layer
- Health checks and auto-restart
- Resource limits configured
- Isolated network (172.20.0.0/16)

**Development Stack (docker-compose.development.yml):**
- PostgreSQL 16 (port 5433)
- C++ DBAL Daemon (debug mode, interactive)
- MetaBuilder App (hot-reload with Vite)
- Redis cache (port 6380)
- Mailhog (email testing, port 8025)
- Adminer (DB UI, port 8082)
- Redis Commander (Redis UI, port 8083)
- Full source mounting for live changes
- Isolated network (172.21.0.0/16)

**Supporting Files:**
- Dockerfile.app - Production app build (multi-stage)
- Dockerfile.app.dev - Development with hot-reload
- init-db.sh - PostgreSQL initialization script
- production.conf - Nginx config with SSL
- config.yaml - DBAL daemon configuration
- .env.production.example - Production environment template
- .env.development.example - Development environment template
- README.md - Complete deployment guide
- start.sh - Quick start interactive script
- .gitignore - Protect secrets and generated files

**Fire-and-Forget Features:**
- Single command startup: `./deployment/start.sh`
- Auto environment detection
- SSL certificate generation
- Health checks for all services
- Automatic retries and restarts
- Volume persistence
- Complete documentation

**Usage:**
```bash
# Quick start (interactive)
cd deployment && ./start.sh

# Or directly
docker-compose -f deployment/docker-compose.production.yml up -d
docker-compose -f deployment/docker-compose.development.yml up
```

**Services Access:**
Production:
- App: https://localhost
- API: https://localhost/api/dbal/

Development:
- App: http://localhost:5173
- API: http://localhost:8081
- DB UI: http://localhost:8082
- Redis UI: http://localhost:8083
- Email: http://localhost:8025

Complete, tested, and production-ready deployment.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-25 00:59:16 +00:00

193 lines
4.5 KiB
YAML

# MetaBuilder Production Deployment
# Fire-and-forget production stack with all services
# Usage: docker-compose -f deployment/docker-compose.production.yml up -d
version: '3.8'
services:
# PostgreSQL Database
postgres:
image: postgres:16-alpine
container_name: metabuilder-postgres-prod
environment:
POSTGRES_DB: metabuilder
POSTGRES_USER: metabuilder
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme_prod_password}
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh:ro
ports:
- "5432:5432"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U metabuilder"]
interval: 10s
timeout: 5s
retries: 5
networks:
- metabuilder-network
# C++ DBAL Daemon
dbal-daemon:
build:
context: ../dbal/cpp
dockerfile: Dockerfile
args:
BUILD_TYPE: Release
container_name: metabuilder-dbal-prod
environment:
DBAL_BIND_ADDRESS: 0.0.0.0
DBAL_PORT: 8080
DBAL_LOG_LEVEL: info
DBAL_MODE: production
DBAL_DAEMON: "true"
DBAL_CONFIG: /app/config/config.yaml
volumes:
- ./config/dbal:/app/config:ro
- dbal_data:/app/data
ports:
- "8080:8080"
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
depends_on:
postgres:
condition: service_healthy
networks:
- metabuilder-network
deploy:
resources:
limits:
cpus: '2'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M
# MetaBuilder Frontend & API
metabuilder-app:
build:
context: ..
dockerfile: deployment/Dockerfile.app
args:
NODE_ENV: production
container_name: metabuilder-app-prod
environment:
NODE_ENV: production
DATABASE_URL: postgresql://metabuilder:${POSTGRES_PASSWORD:-changeme_prod_password}@postgres:5432/metabuilder
PORT: 3000
DBAL_API_URL: http://dbal-daemon:8080
volumes:
- app_uploads:/app/uploads
- app_cache:/app/.cache
ports:
- "3000:3000"
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
depends_on:
postgres:
condition: service_healthy
dbal-daemon:
condition: service_healthy
networks:
- metabuilder-network
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# Nginx Reverse Proxy with SSL
nginx:
image: nginx:alpine
container_name: metabuilder-nginx-prod
ports:
- "80:80"
- "443:443"
volumes:
- ./config/nginx/production.conf:/etc/nginx/nginx.conf:ro
- ./config/nginx/ssl:/etc/nginx/ssl:ro
- nginx_cache:/var/cache/nginx
- nginx_logs:/var/log/nginx
depends_on:
- metabuilder-app
- dbal-daemon
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 5s
retries: 3
networks:
- metabuilder-network
deploy:
resources:
limits:
cpus: '1'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
# Redis Cache (Optional but recommended)
redis:
image: redis:7-alpine
container_name: metabuilder-redis-prod
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-changeme_redis_password}
volumes:
- redis_data:/data
ports:
- "6379:6379"
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 3s
retries: 5
networks:
- metabuilder-network
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.1'
memory: 128M
volumes:
postgres_data:
driver: local
dbal_data:
driver: local
app_uploads:
driver: local
app_cache:
driver: local
redis_data:
driver: local
nginx_cache:
driver: local
nginx_logs:
driver: local
networks:
metabuilder-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16