diff --git a/docker-compose.yml b/docker-compose.yml index f3af36b..9be40eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,91 +1,85 @@ +version: '3.8' + services: - postgres: - image: postgres:15-alpine - environment: - POSTGRES_DB: ${POSTGRES_DB:-linkforty} - POSTGRES_USER: ${POSTGRES_USER:-linkforty} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme} - volumes: - - postgres_data:/var/lib/postgresql/data + # --- Reverse Proxy (Nginx) --- + nginx: + image: nginx:alpine + container_name: linkforty-nginx + restart: always ports: - - "${POSTGRES_PORT:-5432}:5432" - healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-linkforty}"] - interval: 5s - timeout: 5s - retries: 5 - restart: unless-stopped - - redis: - image: redis:7-alpine - command: redis-server --appendonly yes - ports: - - "${REDIS_PORT:-6379}:6379" + - "80:80" + - "443:443" volumes: - - redis_data:/data - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 5s - timeout: 5s - retries: 5 - restart: unless-stopped - - linkforty: - # Use published image (recommended for production) - image: linkforty/core:latest - - # OR build from source (for development) - # Uncomment the lines below and comment out the 'image:' line above - # build: - # context: . - # dockerfile: Dockerfile - + - ./nginx/conf.d:/etc/nginx/conf.d + - ./certbot/conf:/etc/letsencrypt + - ./certbot/www:/var/www/certbot + - ./nginx/well-known:/etc/nginx/well-known:ro depends_on: - postgres: - condition: service_healthy - redis: - condition: service_healthy + - linkforty-prod + - linkforty-sandbox + + # ========================================== + # 1. 운영 (Prod) 환경 + # ========================================== + postgres-prod: + image: postgres:15-alpine + container_name: linkforty-db-prod + restart: always environment: - # Database configuration - DATABASE_URL: postgresql://${POSTGRES_USER:-linkforty}:${POSTGRES_PASSWORD:-changeme}@postgres:5432/${POSTGRES_DB:-linkforty}?sslmode=disable + POSTGRES_USER: linkforty + POSTGRES_PASSWORD: secret_password_prod + POSTGRES_DB: linkforty_prod + volumes: + - pgdata_prod:/var/lib/postgresql/data - # Redis configuration - REDIS_URL: redis://redis:6379 + redis-prod: + image: redis:7-alpine + container_name: linkforty-redis-prod + restart: always - # Server configuration - NODE_ENV: ${NODE_ENV:-production} - PORT: ${PORT:-3000} - HOST: ${HOST:-0.0.0.0} + linkforty-prod: + image: linkforty-custom:latest + container_name: linkforty-core-prod + restart: always + environment: + - DATABASE_URL=postgresql://linkforty:secret_password_prod@postgres-prod:5432/linkforty_prod?sslmode=disable + - REDIS_URL=redis://redis-prod:6379 + - PORT=3000 + depends_on: + - postgres-prod + - redis-prod - # Optional: JWT secret for authentication - # JWT_SECRET: ${JWT_SECRET} + # ========================================== + # 2. 개발 (Sandbox) 환경 + # ========================================== + postgres-sandbox: + image: postgres:15-alpine + container_name: linkforty-db-sandbox + restart: always + environment: + POSTGRES_USER: linkforty + POSTGRES_PASSWORD: secret_password_sandbox + POSTGRES_DB: linkforty_sandbox + volumes: + - pgdata_sandbox:/var/lib/postgresql/data - # Optional: Email configuration - # SMTP_HOST: ${SMTP_HOST} - # SMTP_PORT: ${SMTP_PORT} - # SMTP_USER: ${SMTP_USER} - # SMTP_PASS: ${SMTP_PASS} - # EMAIL_FROM: ${EMAIL_FROM} + redis-sandbox: + image: redis:7-alpine + container_name: linkforty-redis-sandbox + restart: always - ports: - - "${LINKFORTY_PORT:-3000}:3000" - restart: unless-stopped - - # Health check (optional, uncomment if needed) - # healthcheck: - # test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"] - # interval: 30s - # timeout: 10s - # retries: 3 - # start_period: 40s + linkforty-sandbox: + image: linkforty-custom:latest + container_name: linkforty-core-sandbox + restart: always + environment: + - DATABASE_URL=postgresql://linkforty:secret_password_sandbox@postgres-sandbox:5432/linkforty_sandbox?sslmode=disable + - REDIS_URL=redis://redis-sandbox:6379 + - PORT=3001 + depends_on: + - postgres-sandbox + - redis-sandbox volumes: - postgres_data: - driver: local - redis_data: - driver: local - -# Optional: Add network configuration for isolation -# networks: -# linkforty: -# driver: bridge + pgdata_prod: + pgdata_sandbox: