-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
206 lines (183 loc) · 6.81 KB
/
Copy pathdocker-compose.yml
File metadata and controls
206 lines (183 loc) · 6.81 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
version: '3.8'
services:
# Spring Boot Application
app:
image: ${DOCKERHUB_USERNAME}/salemale:latest
container_name: salemale-app
restart: unless-stopped
ports:
- "8080:8080"
environment:
# Database Configuration (RDS)
LOCAL_DB_URL: ${LOCAL_DB_URL}
LOCAL_DB_USERNAME: ${LOCAL_DB_USERNAME}
LOCAL_DB_PASSWORD: ${LOCAL_DB_PASSWORD}
# Admin Configuration
ADMIN_USERNAME: ${ADMIN_USERNAME}
ADMIN_PASSWORD: ${ADMIN_PASSWORD}
# Application Configuration
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE}
SERVER_PORT: ${SERVER_PORT}
# JWT Configuration
JWT_SECRET: ${JWT_SECRET}
# 애플리케이션 프로퍼티 키와 일치하는 만료값 전달
JWT_ACCESS_TOKEN_VALIDITY: ${JWT_ACCESS_TOKEN_VALIDITY}
JWT_REFRESH_TOKEN_VALIDITY: ${JWT_REFRESH_TOKEN_VALIDITY}
# Redis Configuration
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
# Mail Configuration
GOOGLE_EMAIL: ${GOOGLE_EMAIL}
GOOGLE_APP_PW: ${GOOGLE_APP_PW}
# Frontend URL
FRONTEND_URL: ${FRONTEND_URL}
# OAuth2 Configuration - Kakao
KAKAO_CLIENT_ID: ${KAKAO_CLIENT_ID}
KAKAO_CLIENT_SECRET: ${KAKAO_CLIENT_SECRET}
KAKAO_REDIRECT_URI: ${KAKAO_REDIRECT_URI}
# OAuth2 Configuration - Naver
NAVER_CLIENT_ID: ${NAVER_CLIENT_ID}
NAVER_CLIENT_SECRET: ${NAVER_CLIENT_SECRET}
NAVER_REDIRECT_URI: ${NAVER_REDIRECT_URI}
# AWS S3 Configuration
AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
AWS_S3_REGION: ${AWS_S3_REGION}
AWS_ACCESS_KEY: ${AWS_ACCESS_KEY}
AWS_SECRET_KEY: ${AWS_SECRET_KEY}
# Gemini AI Configuration
GEMINI_API_KEY: ${GEMINI_API_KEY}
# Recommendation API Configuration
RECOMMENDATION_API_URL: ${RECOMMENDATION_API_URL}
#NAVER SHOPPING API
NAVER_SHOPPING_CLIENT_ID: ${NAVER_SHOPPING_CLIENT_ID}
NAVER_SHOPPING_CLIENT_SECRET: ${NAVER_SHOPPING_CLIENT_SECRET}
# Timezone / JVM Timezone
TZ: Asia/Seoul
JAVA_TOOL_OPTIONS: -Duser.timezone=Asia/Seoul
depends_on:
- redis
networks:
- salemale-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Redis Cache
redis:
image: redis:7.2
container_name: salemale-redis
restart: unless-stopped
ports:
- "127.0.0.1:6379:6379"
environment:
TZ: Asia/Seoul
networks:
- salemale-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
start_period: 30s
# Prometheus - 메트릭 수집 및 저장
prometheus:
image: prom/prometheus:latest
container_name: salemale-prometheus
restart: unless-stopped
ports:
- "9090:9090" # 외부 접속 가능
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--storage.tsdb.retention.time=7d' # 7일간 데이터 보관 (비용 절감)
- '--web.enable-lifecycle' # 설정 리로드 API 활성화
- '--web.external-url=https://valuebid.site/prometheus' # 외부 접근 URL
- '--web.route-prefix=/' # 내부 경로는 루트로 설정 (Nginx가 /prometheus 처리)
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
networks:
- salemale-network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s # Prometheus 시작 시간 여유
# Grafana - 메트릭 시각화
grafana:
image: grafana/grafana:latest
container_name: salemale-grafana
restart: unless-stopped
ports:
- "3001:3000" # 외부 접속 가능 (기본 포트 3000을 3001로 매핑)
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin} # 환경변수로 설정, 기본값: admin
- GF_USERS_ALLOW_SIGN_UP=false # 회원가입 비활성화
- GF_SERVER_ROOT_URL=https://valuebid.site/grafana # Nginx 경로 기반 접근
- GF_SERVER_SERVE_FROM_SUBPATH=true # 서브 경로에서 서비스 제공
- GF_INSTALL_PLUGINS= # 필요시 플러그인 추가
- TZ=Asia/Seoul
volumes:
- grafana-data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro # 자동 프로비저닝
networks:
- salemale-network
depends_on:
- prometheus
- loki
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
# Loki - 로그 수집 및 저장
# 주석 해제하여 사용하려면 loki/ 및 promtail/ 디렉토리와 설정 파일이 필요합니다
loki:
image: grafana/loki:latest
container_name: salemale-loki
restart: unless-stopped
ports:
- "3100:3100" # 외부 접속 가능
command: -config.file=/etc/loki/local-config.yaml
volumes:
- ./loki/loki-config.yml:/etc/loki/local-config.yaml:ro
- loki-data:/loki
networks:
- salemale-network
healthcheck:
test: ["CMD-SHELL", "wget --quiet --tries=3 --spider http://localhost:3100/ready || exit 1"]
interval: 60s # 헬스체크 간격을 60초로 완화
timeout: 30s # 응답 대기 시간 여유 확대
retries: 10 # 연속 10회 실패 시에만 unhealthy로 간주
start_period: 60s # 초기 부팅 후 60초 동안은 실패를 무시
# Promtail - 로그 수집 에이전트 (Docker 컨테이너 로그 수집) (선택적)
promtail:
image: grafana/promtail:latest
container_name: salemale-promtail
restart: unless-stopped
volumes:
- ./promtail/promtail-config.yml:/etc/promtail/config.yml:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro # Docker 컨테이너 로그 디렉토리
- /var/run/docker.sock:/var/run/docker.sock:ro # Docker 소켓
command: -config.file=/etc/promtail/config.yml
networks:
- salemale-network
depends_on:
- loki
networks:
salemale-network:
name: salemale-network
driver: bridge
# BE compose가 네트워크를 생성 (없으면 생성, 있으면 사용)
# AI compose는 external: true로 이 네트워크 사용
volumes:
redis-data:
prometheus-data: # Prometheus 데이터 저장
grafana-data: # Grafana 데이터 저장
loki-data: # Loki 로그 데이터 저장 (선택적)