-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b329901
commit 8f61643
Showing
10 changed files
with
154 additions
and
143 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
# Eclipse Temurin OpenJDK 17 이미지를 사용 | ||
FROM eclipse-temurin:17-jdk | ||
ARG JAR_FILE=api/build/libs/*.jar | ||
|
||
COPY ${JAR_FILE} app.jar | ||
FROM eclipse-temurin:17-jdk AS builder | ||
WORKDIR application | ||
ARG JAR_FILE=./api/build/libs/*.jar | ||
COPY ${JAR_FILE} application.jar | ||
RUN java -Djarmode=layertools -jar application.jar extract | ||
|
||
# Redis 및 supervisord 설치 | ||
RUN apt-get update && \ | ||
apt-get install -y redis-server supervisor && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# supervisord 설정 파일 복사 | ||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
FROM eclipse-temurin:17-jdk | ||
WORKDIR application | ||
COPY --from=builder application/dependencies/ ./ | ||
COPY --from=builder application/spring-boot-loader/ ./ | ||
COPY --from=builder application/snapshot-dependencies/ ./ | ||
COPY --from=builder application/application/ ./ | ||
|
||
# 포트 노출 | ||
EXPOSE 8080 6379 | ||
# 애플리케이션 JAR 파일이 이미 압축이 해제 되었으므로, JarLauncher를 사용하여 애플리케이션을 시작 | ||
ENV TZ=Asia/Seoul | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-Duser.timezone=Asia/Seoul", "org.springframework.boot.loader.launch.JarLauncher"] | ||
|
||
# supervisord를 사용하여 애플리케이션과 Redis 실행 | ||
CMD ["/usr/bin/supervisord"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
core/core-infra-redis/src/main/resources/application-redis.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
IS_GREEN=$(docker ps | grep green) # 현재 실행중인 App이 green인지 확인합니다. | ||
DEFAULT_CONF=" /etc/nginx/nginx.conf" | ||
|
||
BLUE_PORT=8081 | ||
GREEN_PORT=8082 | ||
|
||
send_failure_message() { | ||
echo "Health check failed after 10 attempts, sending failure message and exiting." | ||
exit 1 | ||
} | ||
|
||
if [ -z $IS_GREEN ]; then # blue인 경우 | ||
|
||
echo "### BLUE => GREEN ###" | ||
|
||
echo "1. get green image" | ||
docker compose pull green # green으로 이미지를 내려받습니다. | ||
|
||
echo "2. green container up" | ||
docker compose up -d green # green 컨테이너 실행 | ||
|
||
for i in {1..15}; do | ||
echo "3. green health check attempt $i..." | ||
sleep 3 | ||
|
||
REQUEST=$(curl http://127.0.0.1:$GREEN_PORT) # green으로 request | ||
if [ -n "$REQUEST" ]; then # 서비스 가능하면 health check 중지 | ||
echo "health check success" | ||
break | ||
elif [ $i -eq 15 ]; then | ||
send_failure_message | ||
fi | ||
done | ||
|
||
echo "4. reload nginx" | ||
sudo cp /etc/nginx/nginx.green.conf /etc/nginx/nginx.conf | ||
sudo nginx -s reload | ||
|
||
echo "5. blue container down" | ||
docker compose stop blue | ||
else | ||
echo "### GREEN => BLUE ###" | ||
|
||
echo "1. get blue image" | ||
docker compose pull blue | ||
|
||
echo "2. blue container up" | ||
docker compose up -d blue | ||
|
||
for i in {1..15}; do | ||
echo "3. blue health check attempt $i..." | ||
sleep 3 | ||
|
||
REQUEST=$(curl http://127.0.0.1:$BLUE_PORT) # blue로 request | ||
|
||
if [ -n "$REQUEST" ]; then # 서비스 가능하면 health check 중지 | ||
echo "health check success" | ||
break | ||
elif [ $i -eq 15 ]; then | ||
send_failure_message | ||
fi | ||
done | ||
|
||
echo "4. reload nginx" | ||
sudo cp /etc/nginx/nginx.blue.conf /etc/nginx/nginx.conf | ||
sudo nginx -s reload | ||
|
||
echo "5. green container down" | ||
docker compose stop green | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
services: | ||
blue: | ||
image: dhxl50/sponus:latest | ||
container_name: blue | ||
ports: | ||
- "8081:8080" | ||
|
||
green: | ||
image: dhxl50/sponus:latest | ||
container_name: green | ||
ports: | ||
- "8082:8080" |
This file was deleted.
Oops, something went wrong.