diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index ba6bcd01..39a2052a 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -79,7 +79,7 @@ jobs: cd ~ # deploy.sh 파일 다운로드 - wget https://raw.githubusercontent.com/Team-Smeme/Smeme-server-renewal/main/script/deploy.sh -O deploy.sh + wget https://raw.githubusercontent.com/Team-Smeme/Smeme-server-renewal/main/script/prod/deploy.sh -O deploy.sh chmod +x deploy.sh # 기존 .env 파일 삭제 및 새로 생성 diff --git a/script/prod/deploy.sh b/script/prod/deploy.sh new file mode 100644 index 00000000..bbd5e753 --- /dev/null +++ b/script/prod/deploy.sh @@ -0,0 +1,64 @@ +#!/bin/bash +source .env + +REGISTRY_URL=${REGISTRY_URL} +IMAGE_NAME=${IMAGE_NAME} +SECRET_MANAGER_TOKEN=${SECRET_MANAGER_TOKEN} +SECRET_MANAGER_WORKSPACE_ID=${SECRET_MANAGER_WORKSPACE_ID} +TAG="latest" +CONTAINER_NAME="smeem" +HEALTH_CHECK_URI="/actuator/health" + +echo "> Stop old version" +if [ "$(sudo docker ps -a -q -f name=${CONTAINER_NAME})" ]; then + docker stop ${CONTAINER_NAME} + docker rm ${CONTAINER_NAME} +fi + +echo "----------------------------------------------------------------------" + +# 도커 이미지 풀 받기 +echo "> Pull Docker Image" +sudo docker pull "${REGISTRY_URL}"/"${IMAGE_NAME}":"${TAG}" + +# 서버 실행 +echo "> Run Docker" + +docker run -d --name ${CONTAINER_NAME} -p 80:8080 \ + -e SECRET_MANAGER_TOKEN="${SECRET_MANAGER_TOKEN}" \ + -e SECRET_MANAGER_WORKSPACE_ID="${SECRET_MANAGER_WORKSPACE_ID}" \ + "${REGISTRY_URL}"/"${IMAGE_NAME}":${TAG} + +echo "----------------------------------------------------------------------" + +# green_port 서버 실행 확인 +sleep 15 + +for retry_count in {1..15} +do + echo "> Health check" + + response=$(curl -s http://localhost${HEALTH_CHECK_URI}) + # shellcheck disable=SC2126 + up_count=$(echo "${response}" | grep 'UP' | wc -l) + + if [ "${up_count}" -ge 1 ] + then + echo "> SUCCESS" + break + else + echo "> Not run yet" + echo "> Response: ${response}" + fi + + if [ "${retry_count}" -eq 15 ] + then + echo "> Failed to running server" + docker rm -f ${CONTAINER_NAME} + exit 1 + fi + + sleep 2 +done + +echo "----------------------------------------------------------------------" diff --git a/smeem-application/src/main/java/com/smeem/application/port/input/dto/request/diary/WriteDiaryRequest.java b/smeem-application/src/main/java/com/smeem/application/port/input/dto/request/diary/WriteDiaryRequest.java index da0e4bc0..c5f920ff 100644 --- a/smeem-application/src/main/java/com/smeem/application/port/input/dto/request/diary/WriteDiaryRequest.java +++ b/smeem-application/src/main/java/com/smeem/application/port/input/dto/request/diary/WriteDiaryRequest.java @@ -24,6 +24,7 @@ public Diary toDomain(Member member) { public Diary toDomain(Diary originDiary) { return Diary.builder() + .id(originDiary.getId()) .content(content) .targetLang(originDiary.getTargetLang()) .topicId(topicId)