-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
152 lines (143 loc) · 3.85 KB
/
docker-compose.yml
File metadata and controls
152 lines (143 loc) · 3.85 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
# CI/CD를 위한 Docker Compose 설정
version: '3.8'
services:
# MySQL Database
mysql:
image: mysql:8.0
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
- ./mysql/init:/docker-entrypoint-initdb.d
ports:
- "3306:3306"
networks:
- dormung-network
restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 20s
retries: 10
interval: 30s
# Redis Cache
redis:
image: redis:7-alpine
container_name: redis
volumes:
- redis_data:/data
ports:
- "6379:6379"
networks:
- dormung-network
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "--no-auth-warning", "ping"]
interval: 30s
timeout: 10s
retries: 3
# SpringBoot Application - Blue dkro
app-blue:
profiles:
- blue
build:
dockerfile: Dockerfile
image: dormung-springboot:latest
container_name: app-blue
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
- SPRING_PROFILES_ACTIVE=prod
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/${MYSQL_DATABASE}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
- SPRING_DATASOURCE_USERNAME=${MYSQL_USER}
- SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD}
- SPRING_DATA_REDIS_HOST=redis
- SPRING_DATA_REDIS_PORT=6379
- SERVER_PORT=8080
- JAVA_OPTS=-Xms256m -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=200
- BUILD_INFO=${BUILD_TAG:-latest}
- DEPLOYMENT_ENV=blue
volumes:
- ./logs/springboot:/app/logs
ports:
- "8080:8080"
networks:
- dormung-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"]
interval: 30s
timeout: 20s
retries: 3
start_period: 120s
# SpringBoot Application - Green
app-green:
profiles:
- green
build:
dockerfile: Dockerfile
image: dormung-springboot:latest
container_name: app-green
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
- SPRING_PROFILES_ACTIVE=prod
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/${MYSQL_DATABASE}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
- SPRING_DATASOURCE_USERNAME=${MYSQL_USER}
- SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD}
- SPRING_DATA_REDIS_HOST=redis
- SPRING_DATA_REDIS_PORT=6379
- SERVER_PORT=8080
- JAVA_OPTS=-Xms256m -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=200
- BUILD_INFO=${BUILD_TAG:-latest}
- DEPLOYMENT_ENV=green
volumes:
- ./logs/springboot:/app/logs
ports:
- "8081:8080"
networks:
- dormung-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"]
interval: 30s
timeout: 20s
retries: 3
start_period: 120s
# Nginx Load Balancer
nginx:
image: nginx:alpine
container_name: nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d:/etc/nginx/conf.d:ro
- ./logs/nginx:/var/log/nginx
- ./static:/var/www/static:ro
ports:
- "19909:19909"
# - "443:443"
networks:
- dormung-network
restart: unless-stopped
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost/health" ]
interval: 30s
timeout: 10s
retries: 3
volumes:
mysql_data:
driver: local
redis_data:
driver: local
networks:
dormung-network:
driver: bridge