-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.multi.yml
More file actions
194 lines (151 loc) · 4.04 KB
/
Copy pathdocker-compose.multi.yml
File metadata and controls
194 lines (151 loc) · 4.04 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
x-app-environment: &app-environment
APP_NAME: ${APP_NAME:-url-shortener}
VIRTUAL_THREADS_ENABLED: ${VIRTUAL_THREADS_ENABLED:-false}
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${DB_NAME:-url_shortener}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
SPRING_DATASOURCE_USERNAME: ${DB_USERNAME:-url_shortener}
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD:?DB_PASSWORD is required}
SPRING_DATA_REDIS_HOST: redis
SPRING_DATA_REDIS_PORT: 6379
REDIS_CONNECT_TIMEOUT: ${REDIS_CONNECT_TIMEOUT:-200ms}
REDIS_COMMAND_TIMEOUT: ${REDIS_COMMAND_TIMEOUT:-200ms}
CACHE_ENABLED: ${CACHE_ENABLED:-true}
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-10}
SHORT_CODE_STRATEGY: distributed
x-app-common: &app-common
build:
context: .
dockerfile: Dockerfile
image: url-shortener:local
expose:
- "8080"
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
[
"CMD",
"curl",
"-fsS",
"http://127.0.0.1:8080/actuator/health"
]
interval: 10s
timeout: 3s
retries: 5
start_period: 20s
services:
app1:
<<: *app-common
environment:
<<: *app-environment
SHORT_CODE_NODE_ID: "1"
app2:
<<: *app-common
environment:
<<: *app-environment
SHORT_CODE_NODE_ID: "2"
nginx:
image: nginx:1.30.4-alpine
ports:
- "${APP_PORT:-8080}:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
app1:
condition: service_healthy
app2:
condition: service_healthy
healthcheck:
test:
[
"CMD-SHELL",
"wget -qO- http://127.0.0.1/nginx-health | grep -q ok"
]
interval: 5s
timeout: 3s
retries: 10
mysql:
image: mysql:8.4
environment:
MYSQL_DATABASE: ${DB_NAME:-url_shortener}
MYSQL_USER: ${DB_USERNAME:-url_shortener}
MYSQL_PASSWORD: ${DB_PASSWORD:?DB_PASSWORD is required}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?MYSQL_ROOT_PASSWORD is required}
ports:
- "${MYSQL_PORT:-3306}:3306"
volumes:
- mysql-data-multi:/var/lib/mysql
healthcheck:
test:
[
"CMD-SHELL",
"mysqladmin ping -h localhost -u root -p$$MYSQL_ROOT_PASSWORD"
]
interval: 5s
timeout: 3s
retries: 10
redis:
image: redis:7.4-alpine
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis-data-multi:/data
healthcheck:
test:
[
"CMD",
"redis-cli",
"ping"
]
interval: 5s
timeout: 3s
retries: 10
prometheus:
image: prom/prometheus:v3.13.0
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
- ./monitoring/prometheus/prometheus-multi.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data-multi:/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.enable-lifecycle
depends_on:
app1:
condition: service_healthy
app2:
condition: service_healthy
grafana:
image: grafana/grafana:13.1.1-ubuntu
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:-admin}
GF_USERS_ALLOW_SIGN_UP: "false"
volumes:
- grafana-data:/var/lib/grafana
- ./monitoring/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./monitoring/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
depends_on:
- prometheus
k6:
image: grafana/k6:2.1.0
profiles:
- test
environment:
BASE_URL: http://nginx
volumes:
- ./k6:/scripts:ro
depends_on:
nginx:
condition: service_healthy
volumes:
mysql-data-multi:
redis-data-multi:
prometheus-data-multi:
grafana-data: