-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
132 lines (123 loc) · 3.46 KB
/
docker-compose.prod.yml
File metadata and controls
132 lines (123 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
version: '3.8'
# 프로덕션용 Docker Compose 설정
# 사용법: docker-compose -f docker-compose.prod.yml up -d
services:
# ==================================
# Auth Service (Production)
# ==================================
auth:
build:
context: . # Monorepo 루트
dockerfile: services/auth/Dockerfile
ports:
- "8000:8000"
env_file:
- ./.env.production # 프로덕션 환경 변수 파일
environment:
- PYTHONPATH=/home/appuser
# 프로덕션에서는 볼륨 마운트 없이 이미지 내부 코드 사용
restart: always
depends_on:
db:
condition: service_healthy
networks:
- dash-network
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# ==================================
# Coupon Service (Production)
# ==================================
coupon:
build:
context: . # Monorepo 루트
dockerfile: services/coupon/Dockerfile
ports:
- "8002:8002"
env_file:
- ./.env.production # 프로덕션 환경 변수 파일
environment:
- PYTHONPATH=/home/appuser
# 프로덕션에서는 볼륨 마운트 없이 이미지 내부 코드 사용
restart: always
depends_on:
db:
condition: service_healthy
networks:
- dash-network
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8002/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# ==================================
# MySQL Database (Production)
# ==================================
db:
image: mysql:8.0
restart: always
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
- MYSQL_DATABASE=dash_db
- MYSQL_USER_FILE=/run/secrets/mysql_user
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
ports:
- "3306:3306" # 프로덕션에서는 외부 노출 제거 권장
volumes:
# 프로덕션에서는 named volume 또는 외부 스토리지 사용 권장
- mysql_data:/var/lib/mysql
# 초기 DDL 스크립트 마운트 (선택사항)
- ./libs/schemas/ddl.sql:/docker-entrypoint-initdb.d/init.sql:ro
secrets:
- mysql_root_password
- mysql_user
- mysql_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- dash-network
# 보안: 외부 접근 제한 (필요시)
# command: --bind-address=0.0.0.0 --skip-networking=0
# ==================================
# Database Initialization (Optional)
# ==================================
# db-init:
# image: mysql:8.0
# depends_on:
# db:
# condition: service_healthy
# volumes:
# - ./libs/schemas/ddl.sql:/ddl.sql:ro
# command: >
# sh -c "
# mysql -h db -u root -p$$MYSQL_ROOT_PASSWORD dash_db < /ddl.sql
# "
# environment:
# - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
# secrets:
# - mysql_root_password
# networks:
# - dash-network
networks:
dash-network:
driver: bridge
volumes:
mysql_data:
driver: local
secrets:
mysql_root_password:
file: ./secrets/mysql_root_password.txt
mysql_user:
file: ./secrets/mysql_user.txt
mysql_password:
file: ./secrets/mysql_password.txt