Skip to content

Commit c5ee6c5

Browse files
committed
change deploy.yml
1 parent c8a3382 commit c5ee6c5

3 files changed

Lines changed: 39 additions & 41 deletions

File tree

docker-compose.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ services:
4545

4646
# SpringBoot Application - Blue
4747
app-blue:
48+
profiles:
49+
- blue
4850
build:
4951
dockerfile: Dockerfile
5052
image: dormung-springboot:latest
@@ -56,12 +58,11 @@ services:
5658
condition: service_healthy
5759
environment:
5860
- SPRING_PROFILES_ACTIVE=prod
59-
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/${MYSQL_DATABASE:-dormung}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
60-
- SPRING_DATASOURCE_USERNAME=${MYSQL_USER:-dormung_user}
61-
- SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD:-dormung_password}
61+
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/${MYSQL_DATABASE}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
62+
- SPRING_DATASOURCE_USERNAME=${MYSQL_USER}
63+
- SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD}
6264
- SPRING_DATA_REDIS_HOST=redis
6365
- SPRING_DATA_REDIS_PORT=6379
64-
- SPRING_DATA_REDIS_PASSWORD=${REDIS_PASSWORD:-}
6566
- SERVER_PORT=8080
6667
- JAVA_OPTS=-Xms256m -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=200
6768
- BUILD_INFO=${BUILD_TAG:-latest}
@@ -74,14 +75,16 @@ services:
7475
- dormung-network
7576
restart: unless-stopped
7677
healthcheck:
77-
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
78+
test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"]
7879
interval: 30s
79-
timeout: 10s
80+
timeout: 20s
8081
retries: 3
81-
start_period: 60s
82+
start_period: 120s
8283

8384
# SpringBoot Application - Green
8485
app-green:
86+
profiles:
87+
- green
8588
build:
8689
dockerfile: Dockerfile
8790
image: dormung-springboot:latest
@@ -93,12 +96,11 @@ services:
9396
condition: service_healthy
9497
environment:
9598
- SPRING_PROFILES_ACTIVE=prod
96-
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/${MYSQL_DATABASE:-dormung}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
97-
- SPRING_DATASOURCE_USERNAME=${MYSQL_USER:-dormung_user}
98-
- SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD:-dormung_password}
99+
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/${MYSQL_DATABASE}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
100+
- SPRING_DATASOURCE_USERNAME=${MYSQL_USER}
101+
- SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD}
99102
- SPRING_DATA_REDIS_HOST=redis
100103
- SPRING_DATA_REDIS_PORT=6379
101-
- SPRING_DATA_REDIS_PASSWORD=${REDIS_PASSWORD:-}
102104
- SERVER_PORT=8080
103105
- JAVA_OPTS=-Xms256m -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=200
104106
- BUILD_INFO=${BUILD_TAG:-latest}
@@ -111,20 +113,17 @@ services:
111113
- dormung-network
112114
restart: unless-stopped
113115
healthcheck:
114-
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
116+
test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"]
115117
interval: 30s
116-
timeout: 10s
118+
timeout: 20s
117119
retries: 3
118-
start_period: 60s
119-
profiles:
120-
- green
120+
start_period: 120s
121+
121122

122123
# Nginx Load Balancer
123124
nginx:
124125
image: nginx:alpine
125126
container_name: nginx
126-
depends_on:
127-
- app-blue
128127
volumes:
129128
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
130129
- ./nginx/conf.d:/etc/nginx/conf.d:ro
@@ -137,7 +136,7 @@ services:
137136
- dormung-network
138137
restart: unless-stopped
139138
healthcheck:
140-
test: ["CMD", "curl", "-f", "http://localhost/health"]
139+
test: [ "CMD", "curl", "-f", "http://localhost/health" ]
141140
interval: 30s
142141
timeout: 10s
143142
retries: 3

nginx/nginx.conf

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ events {
44

55
http {
66
upstream springboot {
7-
server springboot-blue:8080 max_fails=3 fail_timeout=30s;
8-
# server springboot-green:8080 max_fails=3 fail_timeout=30s;
9-
}
10-
11-
upstream python {
12-
server python-app:8000 max_fails=3 fail_timeout=30s;
7+
server app-blue:8080 max_fails=3 fail_timeout=30s;
8+
# server app-green:8080 max_fails=3 fail_timeout=30s;
139
}
1410

1511
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
@@ -24,9 +20,19 @@ http {
2420
listen 80;
2521
server_name localhost;
2622

23+
# CORS 설정
24+
add_header Access-Control-Allow-Origin "https://dormung.netlify.app" always;
25+
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
26+
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
27+
28+
# OPTIONS 요청 처리
29+
if ($request_method = 'OPTIONS') {
30+
return 204;
31+
}
32+
2733
# SpringBoot API
2834
location /api/ {
29-
proxy_pass http://springboot/;
35+
proxy_pass http://springboot/api/;
3036
proxy_set_header Host $host;
3137
proxy_set_header X-Real-IP $remote_addr;
3238
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -35,7 +41,6 @@ http {
3541
proxy_set_header Connection "";
3642
}
3743

38-
3944
# Health check
4045
location /health {
4146
access_log off;

src/main/resources/application.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
spring:
22
application:
3-
name: dormung-springboot
3+
name: srpingboot-app
4+
profiles:
5+
active: "prod"
46

5-
# Database
67
datasource:
7-
url: "jdbc:mysql://localhost:3306/jeju_audio_guide?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul"
8-
username: ${SPRING_DATASOURCE_USERNAME}
9-
password: ${MYSQL_ROOT_PASSWORD}
8+
url: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
9+
username: ${MYSQL_USER}
10+
password: ${MYSQL_PASSWORD}
1011
driver-class-name: com.mysql.cj.jdbc.Driver
1112

12-
# JPA/Hibernate
1313
jpa:
1414
hibernate:
1515
ddl-auto: update
@@ -19,21 +19,18 @@ spring:
1919
dialect: org.hibernate.dialect.MySQL8Dialect
2020
format_sql: true
2121

22-
# Redis
2322
data:
2423
redis:
25-
host: ${SPRING_DATA_REDIS_HOST:localhost}
24+
host: ${SPRING_DATA_REDIS_HOST:redis}
2625
port: ${SPRING_DATA_REDIS_PORT:6379}
2726
timeout: 2000ms
2827

29-
# Server
3028
server:
3129
port: ${SERVER_PORT:8080}
3230
servlet:
3331
context-path: /api
3432
shutdown: graceful
3533

36-
# Actuator
3734
management:
3835
endpoints:
3936
web:
@@ -43,11 +40,8 @@ management:
4340
health:
4441
show-details: always
4542

46-
# Logging
4743
logging:
4844
level:
4945
com.mycompany.goormthonserver: INFO
5046
org.springframework.web: WARN
51-
org.hibernate.SQL: WARN
52-
pattern:
53-
console: "%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
47+
org.hibernate.SQL: WARN

0 commit comments

Comments
 (0)