- Docker: Multi-stage Dockerfile with security hardening, docker-compose for production and development environments - Environment: Comprehensive .env.example with all config options, lib/config/env.ts for typed environment validation - Logging: Structured JSON logging with request/response middleware - Monitoring: Prometheus metrics endpoint, Grafana dashboard, health checks (liveness/readiness probes) - Security: Security headers, rate limiting, CORS middleware - CI/CD: GitHub Actions workflows for CI, production deploy, and preview deployments - Error tracking: Sentry integration foundation Files created: - Docker: Dockerfile, docker-compose.yml, docker-compose.dev.yml, .dockerignore - Config: lib/config/env.ts, lib/config/index.ts - Logging: lib/logging/logger.ts, lib/logging/middleware.ts - Monitoring: lib/monitoring/sentry.ts, lib/monitoring/metrics.ts, lib/monitoring/health.ts - Security: lib/security/headers.ts, lib/security/rateLimit.ts, lib/security/cors.ts - API: pages/api/health/*, pages/api/metrics.ts - Infra: infra/prometheus/prometheus.yml, infra/grafana/*
155 lines
4.5 KiB
YAML
155 lines
4.5 KiB
YAML
# LocalGreenChain Development Docker Compose
|
|
# Agent 4: Production Deployment
|
|
# Development environment with hot reloading and debug tools
|
|
|
|
version: '3.8'
|
|
|
|
services:
|
|
# ==========================================================================
|
|
# Application (Development Mode)
|
|
# ==========================================================================
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
target: deps # Use deps stage for development
|
|
container_name: lgc-app-dev
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${PORT:-3001}:3001"
|
|
environment:
|
|
- NODE_ENV=development
|
|
- DATABASE_URL=postgresql://lgc:lgc_dev_password@postgres:5432/localgreenchain_dev
|
|
- REDIS_URL=redis://redis:6379
|
|
- LOG_LEVEL=debug
|
|
- PLANTS_NET_API_KEY=${PLANTS_NET_API_KEY:-}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
volumes:
|
|
# Mount source code for hot reloading
|
|
- .:/app
|
|
- /app/node_modules # Exclude node_modules
|
|
- /app/.next # Exclude build output
|
|
networks:
|
|
- lgc-dev-network
|
|
command: bun run dev
|
|
|
|
# ==========================================================================
|
|
# Database (Development)
|
|
# ==========================================================================
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: lgc-postgres-dev
|
|
restart: unless-stopped
|
|
environment:
|
|
- POSTGRES_USER=lgc
|
|
- POSTGRES_PASSWORD=lgc_dev_password
|
|
- POSTGRES_DB=localgreenchain_dev
|
|
volumes:
|
|
- postgres-dev-data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5433:5432" # Different port to avoid conflicts
|
|
networks:
|
|
- lgc-dev-network
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U lgc -d localgreenchain_dev"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ==========================================================================
|
|
# Cache (Development)
|
|
# ==========================================================================
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: lgc-redis-dev
|
|
restart: unless-stopped
|
|
command: redis-server --appendonly yes
|
|
volumes:
|
|
- redis-dev-data:/data
|
|
ports:
|
|
- "6380:6379" # Different port to avoid conflicts
|
|
networks:
|
|
- lgc-dev-network
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ==========================================================================
|
|
# Database Admin (pgAdmin)
|
|
# ==========================================================================
|
|
pgadmin:
|
|
image: dpage/pgadmin4:latest
|
|
container_name: lgc-pgadmin-dev
|
|
restart: unless-stopped
|
|
environment:
|
|
- PGADMIN_DEFAULT_EMAIL=admin@localgreenchain.local
|
|
- PGADMIN_DEFAULT_PASSWORD=admin
|
|
- PGADMIN_CONFIG_SERVER_MODE=False
|
|
volumes:
|
|
- pgadmin-dev-data:/var/lib/pgadmin
|
|
ports:
|
|
- "5050:80"
|
|
networks:
|
|
- lgc-dev-network
|
|
depends_on:
|
|
- postgres
|
|
profiles:
|
|
- tools
|
|
|
|
# ==========================================================================
|
|
# Redis Commander (Redis UI)
|
|
# ==========================================================================
|
|
redis-commander:
|
|
image: rediscommander/redis-commander:latest
|
|
container_name: lgc-redis-commander-dev
|
|
restart: unless-stopped
|
|
environment:
|
|
- REDIS_HOSTS=local:redis:6379
|
|
ports:
|
|
- "8081:8081"
|
|
networks:
|
|
- lgc-dev-network
|
|
depends_on:
|
|
- redis
|
|
profiles:
|
|
- tools
|
|
|
|
# ==========================================================================
|
|
# MailHog (Email Testing)
|
|
# ==========================================================================
|
|
mailhog:
|
|
image: mailhog/mailhog:latest
|
|
container_name: lgc-mailhog-dev
|
|
restart: unless-stopped
|
|
ports:
|
|
- "1025:1025" # SMTP
|
|
- "8025:8025" # Web UI
|
|
networks:
|
|
- lgc-dev-network
|
|
profiles:
|
|
- tools
|
|
|
|
# =============================================================================
|
|
# Networks
|
|
# =============================================================================
|
|
networks:
|
|
lgc-dev-network:
|
|
driver: bridge
|
|
name: lgc-dev-network
|
|
|
|
# =============================================================================
|
|
# Volumes
|
|
# =============================================================================
|
|
volumes:
|
|
postgres-dev-data:
|
|
name: lgc-postgres-dev-data
|
|
redis-dev-data:
|
|
name: lgc-redis-dev-data
|
|
pgadmin-dev-data:
|
|
name: lgc-pgadmin-dev-data
|