Files
document-server/docker-compose.synology.yml

179 lines
5.2 KiB
YAML

version: '3.8'
services:
# PostgreSQL 데이터베이스 (SSD 최적화 - 32GB RAM 활용)
database:
image: postgres:15-alpine
container_name: document-server-db
restart: unless-stopped
environment:
POSTGRES_DB: document_db
POSTGRES_USER: docuser
POSTGRES_PASSWORD: ${DB_PASSWORD:-docpass}
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
volumes:
# SSD: 데이터베이스 (성능 최우선)
- /volume3/docker/document-server/database:/var/lib/postgresql/data
- /volume3/docker/document-server/config/postgresql.synology.conf:/etc/postgresql/postgresql.conf:ro
- ./database/init:/docker-entrypoint-initdb.d: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=512MB
-c maintenance_work_mem=4GB
-c checkpoint_completion_target=0.9
-c wal_buffers=128MB
-c random_page_cost=1.1
-c effective_io_concurrency=200
-c max_worker_processes=8
-c max_parallel_workers_per_gather=4
-c max_parallel_workers=8
healthcheck:
test: ["CMD-SHELL", "pg_isready -U docuser -d document_db"]
interval: 30s
timeout: 10s
retries: 3
networks:
- document-network
deploy:
resources:
limits:
memory: 10G
reservations:
memory: 2G
# Redis 캐시 (SSD 최적화 - 대용량 메모리 활용)
redis:
image: redis:7-alpine
container_name: document-server-redis
restart: unless-stopped
volumes:
# SSD: Redis 데이터 (빠른 캐시)
- /volume3/docker/document-server/redis:/data
ports:
- "24103:6379"
command: >
redis-server
--maxmemory 8gb
--maxmemory-policy allkeys-lru
--save 900 1
--save 300 10
--save 60 10000
--appendonly yes
--appendfsync everysec
--auto-aof-rewrite-percentage 100
--auto-aof-rewrite-min-size 64mb
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
networks:
- document-network
deploy:
resources:
limits:
memory: 10G
reservations:
memory: 1G
# FastAPI 백엔드 (SSD에서 실행, HDD 스토리지 연결)
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: document-server-backend
restart: unless-stopped
environment:
- DATABASE_URL=postgresql+asyncpg://docuser:${DB_PASSWORD:-docpass}@database:5432/document_db
- REDIS_URL=redis://redis:6379/0
- 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://${DOMAIN_NAME:-localhost}
- UPLOAD_DIR=/app/uploads
- MAX_FILE_SIZE=500000000
volumes:
# SSD: 애플리케이션 로그 및 설정 (빠른 액세스)
- /volume3/docker/document-server/logs:/app/logs
- /volume3/docker/document-server/config:/app/config
- /volume3/docker/document-server/cache:/app/cache
# HDD: 대용량 파일 저장소 (비용 효율적)
- /volume1/document-storage/uploads:/app/uploads
- /volume1/document-storage/documents:/app/documents
- /volume1/document-storage/thumbnails:/app/thumbnails
- /volume1/document-storage/backups:/app/backups
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
deploy:
resources:
limits:
memory: 4G
reservations:
memory: 512M
# Nginx 웹서버 (SSD 캐시, HDD 스토리지)
nginx:
build:
context: ./nginx
dockerfile: Dockerfile
container_name: document-server-nginx
restart: unless-stopped
volumes:
# SSD: Nginx 설정, 로그, 캐시 (성능 최적화)
- /volume3/docker/document-server/nginx/conf.d:/etc/nginx/conf.d
- /volume3/docker/document-server/nginx/cache:/var/cache/nginx
- /volume3/docker/document-server/logs/nginx:/var/log/nginx
# SSD: 프론트엔드 정적 파일 (빠른 서빙)
- ./frontend:/usr/share/nginx/html:ro
# HDD: 대용량 문서 파일 (읽기 전용)
- /volume1/document-storage/uploads:/usr/share/nginx/html/uploads:ro
- /volume1/document-storage/documents:/usr/share/nginx/html/documents:ro
ports:
- "24100:80"
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 30s
timeout: 10s
retries: 3
networks:
- document-network
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 128M
networks:
document-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
# 볼륨 정의는 제거 (직접 경로 매핑 사용)