Docker Compose 파일 정리: 불필요한 파일 제거, 3개 파일로 단순화
This commit is contained in:
@@ -1,134 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
# Nginx 리버스 프록시 (프로덕션)
|
|
||||||
nginx:
|
|
||||||
build: ./nginx
|
|
||||||
container_name: document-server-nginx-prod
|
|
||||||
ports:
|
|
||||||
- "24100:80"
|
|
||||||
volumes:
|
|
||||||
- ./frontend:/usr/share/nginx/html:ro
|
|
||||||
- ./uploads:/usr/share/nginx/html/uploads:ro
|
|
||||||
- nginx_cache:/var/cache/nginx
|
|
||||||
depends_on:
|
|
||||||
- backend
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- NGINX_WORKER_PROCESSES=auto
|
|
||||||
- NGINX_WORKER_CONNECTIONS=1024
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
|
|
||||||
# Backend API 서버 (프로덕션)
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: ./backend
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: document-server-backend-prod
|
|
||||||
ports:
|
|
||||||
- "24102:8000"
|
|
||||||
volumes:
|
|
||||||
- ./uploads:/app/uploads
|
|
||||||
- backend_logs:/app/logs
|
|
||||||
environment:
|
|
||||||
- DATABASE_URL=postgresql+asyncpg://docuser:${DB_PASSWORD:-docpass}@database:5432/document_db
|
|
||||||
- SECRET_KEY=${SECRET_KEY:-production-secret-key-change-this}
|
|
||||||
- ADMIN_EMAIL=${ADMIN_EMAIL:-admin@test.com}
|
|
||||||
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin123}
|
|
||||||
- DEBUG=false
|
|
||||||
- ALLOWED_ORIGINS=http://localhost:24100,https://your-domain.com
|
|
||||||
depends_on:
|
|
||||||
database:
|
|
||||||
condition: service_healthy
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: 2G
|
|
||||||
reservations:
|
|
||||||
memory: 512M
|
|
||||||
|
|
||||||
# PostgreSQL 데이터베이스 (프로덕션)
|
|
||||||
database:
|
|
||||||
image: postgres:15-alpine
|
|
||||||
container_name: document-server-db-prod
|
|
||||||
ports:
|
|
||||||
- "24101:5432"
|
|
||||||
environment:
|
|
||||||
- POSTGRES_DB=document_db
|
|
||||||
- POSTGRES_USER=docuser
|
|
||||||
- POSTGRES_PASSWORD=${DB_PASSWORD:-docpass}
|
|
||||||
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --locale=C
|
|
||||||
volumes:
|
|
||||||
- postgres_data:/var/lib/postgresql/data
|
|
||||||
- ./database/init:/docker-entrypoint-initdb.d:ro
|
|
||||||
- ./config/postgresql.prod.conf:/etc/postgresql/postgresql.conf:ro
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U docuser -d document_db"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 5
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: 4G
|
|
||||||
reservations:
|
|
||||||
memory: 1G
|
|
||||||
|
|
||||||
# Redis (캐싱 및 세션) - 프로덕션
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
container_name: document-server-redis-prod
|
|
||||||
ports:
|
|
||||||
- "24103:6379"
|
|
||||||
volumes:
|
|
||||||
- redis_data:/data
|
|
||||||
- ./config/redis.prod.conf:/usr/local/etc/redis/redis.conf:ro
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
restart: unless-stopped
|
|
||||||
command: redis-server /usr/local/etc/redis/redis.conf
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: 1G
|
|
||||||
reservations:
|
|
||||||
memory: 256M
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
postgres_data:
|
|
||||||
driver: local
|
|
||||||
redis_data:
|
|
||||||
driver: local
|
|
||||||
nginx_cache:
|
|
||||||
driver: local
|
|
||||||
backend_logs:
|
|
||||||
driver: local
|
|
||||||
|
|
||||||
networks:
|
|
||||||
document-network:
|
|
||||||
driver: bridge
|
|
||||||
ipam:
|
|
||||||
config:
|
|
||||||
- subnet: 172.20.0.0/16
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
# PostgreSQL 데이터베이스 (SSD 최적화)
|
|
||||||
database:
|
|
||||||
image: postgres:15-alpine
|
|
||||||
container_name: document-server-db
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: document_server
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres123}
|
|
||||||
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
|
|
||||||
volumes:
|
|
||||||
# SSD: 데이터베이스 성능 최적화
|
|
||||||
- /volume1/docker/document-server/database:/var/lib/postgresql/data
|
|
||||||
- /volume1/docker/document-server/config/postgresql.conf:/etc/postgresql/postgresql.conf:ro
|
|
||||||
ports:
|
|
||||||
- "24101:5432"
|
|
||||||
command: >
|
|
||||||
postgres
|
|
||||||
-c config_file=/etc/postgresql/postgresql.conf
|
|
||||||
-c shared_buffers=8GB
|
|
||||||
-c effective_cache_size=24GB
|
|
||||||
-c work_mem=256MB
|
|
||||||
-c maintenance_work_mem=2GB
|
|
||||||
-c checkpoint_completion_target=0.9
|
|
||||||
-c wal_buffers=64MB
|
|
||||||
-c random_page_cost=1.1
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
|
|
||||||
# Redis 캐시 (SSD 최적화)
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
container_name: document-server-redis
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
# SSD: 캐시 성능 최적화
|
|
||||||
- /volume1/docker/document-server/redis:/data
|
|
||||||
ports:
|
|
||||||
- "24103:6379"
|
|
||||||
command: >
|
|
||||||
redis-server
|
|
||||||
--maxmemory 4gb
|
|
||||||
--maxmemory-policy allkeys-lru
|
|
||||||
--save 900 1
|
|
||||||
--save 300 10
|
|
||||||
--save 60 10000
|
|
||||||
--appendonly yes
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
|
|
||||||
# FastAPI 백엔드
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: ./backend
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: document-server-backend
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- DATABASE_URL=postgresql://postgres:${DB_PASSWORD:-postgres123}@database:5432/document_server
|
|
||||||
- REDIS_URL=redis://redis:6379
|
|
||||||
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-your-super-secret-jwt-key-change-this-in-production}
|
|
||||||
- ENVIRONMENT=production
|
|
||||||
- LOG_LEVEL=INFO
|
|
||||||
volumes:
|
|
||||||
# SSD: 로그 및 설정 (빠른 액세스)
|
|
||||||
- /volume1/docker/document-server/logs:/app/logs
|
|
||||||
- /volume1/docker/document-server/config:/app/config
|
|
||||||
# HDD: 대용량 파일 저장 (비용 효율적)
|
|
||||||
- /volume2/document-storage/uploads:/app/uploads
|
|
||||||
- /volume2/document-storage/documents:/app/documents
|
|
||||||
ports:
|
|
||||||
- "24102:8000"
|
|
||||||
depends_on:
|
|
||||||
database:
|
|
||||||
condition: service_healthy
|
|
||||||
redis:
|
|
||||||
condition: service_healthy
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
|
|
||||||
# Nginx 웹서버
|
|
||||||
nginx:
|
|
||||||
build:
|
|
||||||
context: ./nginx
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: document-server-nginx
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
# SSD: 설정 및 캐시 (빠른 액세스)
|
|
||||||
- /volume1/docker/document-server/nginx:/etc/nginx/conf.d
|
|
||||||
- /volume1/docker/document-server/logs/nginx:/var/log/nginx
|
|
||||||
# HDD: 정적 파일 서빙 (읽기 전용)
|
|
||||||
- /volume2/document-storage/documents:/usr/share/nginx/html/documents:ro
|
|
||||||
- ./frontend:/usr/share/nginx/html:ro
|
|
||||||
ports:
|
|
||||||
- "24100:80"
|
|
||||||
depends_on:
|
|
||||||
backend:
|
|
||||||
condition: service_healthy
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:80/health"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
networks:
|
|
||||||
- document-network
|
|
||||||
|
|
||||||
networks:
|
|
||||||
document-network:
|
|
||||||
driver: bridge
|
|
||||||
ipam:
|
|
||||||
config:
|
|
||||||
- subnet: 172.20.0.0/16
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
# 명시적 볼륨 정의 (시놀로지 경로 매핑)
|
|
||||||
database_data:
|
|
||||||
driver: local
|
|
||||||
driver_opts:
|
|
||||||
type: none
|
|
||||||
o: bind
|
|
||||||
device: /volume1/docker/document-server/database
|
|
||||||
|
|
||||||
redis_data:
|
|
||||||
driver: local
|
|
||||||
driver_opts:
|
|
||||||
type: none
|
|
||||||
o: bind
|
|
||||||
device: /volume1/docker/document-server/redis
|
|
||||||
|
|
||||||
document_storage:
|
|
||||||
driver: local
|
|
||||||
driver_opts:
|
|
||||||
type: none
|
|
||||||
o: bind
|
|
||||||
device: /volume2/document-storage
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user