-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
161 lines (148 loc) · 4.72 KB
/
docker-compose.prod.yml
File metadata and controls
161 lines (148 loc) · 4.72 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
version: '3.8'
# 프로덕션 환경용 docker-compose 설정
# 사용법: docker-compose -f docker-compose.dev.yml -f docker-compose.prod.yml up -d
#
# ⚠️ 포트 설정 (개발 환경과 동시 실행 시 충돌 방지):
# - MySQL: 3306 (외부) -> 3306 (내부) - 개발(3307)과 다름
# - Redis: 6379 (외부) -> 6379 (내부) - 개발(6380)과 다름
# - Backend: 8080 (외부) -> 8080 (내부) - 개발(8081)과 다름
services:
# Taba Backend 애플리케이션 (프로덕션용)
backend:
build:
context: .
dockerfile: Dockerfile
container_name: taba-backend-prod
restart: unless-stopped
environment:
# Spring Profile (프로덕션용)
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
# MySQL 설정
DB_HOST: ${DB_HOST:-mysql}
DB_PORT: ${DB_PORT:-3306}
DB_NAME: ${DB_NAME}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
# Redis 설정
REDIS_HOST: ${REDIS_HOST:-redis}
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
# JWT 설정
JWT_SECRET: ${JWT_SECRET}
JWT_EXPIRATION: ${JWT_EXPIRATION:-604800000}
# 서버 설정
SERVER_PORT: ${SERVER_PORT:-8080}
SERVER_URL: ${SERVER_URL}
# 파일 업로드 설정
FILE_UPLOAD_DIR: ${FILE_UPLOAD_DIR:-/app/uploads}
# 메일 설정 (비밀번호 찾기 기능용, 선택사항)
MAIL_HOST: ${MAIL_HOST:-smtp.gmail.com}
MAIL_PORT: ${MAIL_PORT:-587}
MAIL_USERNAME: ${MAIL_USERNAME:-}
MAIL_PASSWORD: ${MAIL_PASSWORD:-}
FRONTEND_URL: ${FRONTEND_URL:-http://localhost:3000}
ports:
# ⚠️ 외부 포트 노출 (프로덕션용 API 접속 허용)
# 외부 접속: 서버IP:8080 (개발 8081과 다름 - 동시 실행 가능)
# 내부 접속: localhost:8080
- "${EXTERNAL_PORT:-8080}:8080"
volumes:
- uploads_data_prod:/app/uploads
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/api/v1/actuator/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
networks:
- taba-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# MySQL 데이터베이스 (프로덕션용)
mysql:
image: mysql:8.0
container_name: taba-mysql-prod
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
TZ: Asia/Seoul
ports:
# ⚠️ 외부 포트 노출 (프로덕션용 DB 접속 허용)
# 외부 접속: 서버IP:3306 (개발 3307과 다름 - 동시 실행 가능)
# 내부 접속: mysql:3306
- "${DB_EXTERNAL_PORT:-3306}:3306"
volumes:
- mysql_data_prod:/var/lib/mysql
- ./src/main/resources/db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- taba-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Redis (프로덕션용)
redis:
image: redis:7-alpine
container_name: taba-redis-prod
restart: unless-stopped
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
command:
- sh
- -c
- |
if [ -n "$$REDIS_PASSWORD" ]; then
redis-server --appendonly yes --requirepass "$$REDIS_PASSWORD"
else
redis-server --appendonly yes
fi
ports:
# ⚠️ 외부 포트 노출 (프로덕션용 Redis 접속 허용)
# 외부 접속: 서버IP:6379 (개발 6380과 다름 - 동시 실행 가능)
# 내부 접속: redis:6379
- "${REDIS_EXTERNAL_PORT:-6379}:6379"
volumes:
- redis_data_prod:/data
healthcheck:
test: ["CMD-SHELL", "if [ -n \"$$REDIS_PASSWORD\" ]; then redis-cli -a \"$$REDIS_PASSWORD\" ping || exit 1; else redis-cli ping || exit 1; fi"]
interval: 10s
timeout: 3s
retries: 5
networks:
- taba-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
volumes:
mysql_data_prod:
driver: local
redis_data_prod:
driver: local
uploads_data_prod:
driver: local
networks:
taba-network:
driver: bridge