-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from eod940/050-FEAT-CD
feat: [050-FEAT-CD] CD 기능 구축
- Loading branch information
Showing
4 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
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,24 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
- source: / | ||
destination: /home/ubuntu/deploy/ | ||
overwrite: yes | ||
|
||
permissions: | ||
- object: /home/ubuntu/deploy/ | ||
pattern: "**" | ||
owner: root | ||
group: root | ||
mode: 777 | ||
|
||
hooks: | ||
ApplicationStop: | ||
- location: scripts/stop.sh | ||
timeout: 60 | ||
runas: root | ||
|
||
ApplicationStart: | ||
- location: scripts/start.sh | ||
timeout: 60 | ||
runas: root |
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,43 @@ | ||
IMAGE_FILE_PATH="/home/ubuntu/deploy/image.txt" | ||
IMAGE_NAME=$(cat "$IMAGE_FILE_PATH") | ||
CONTAINER_ENV_PATH="/home/ubuntu/trip.env" | ||
SERVICE_NAME=tweaver | ||
|
||
# Docker Compose YAML을 새로운 도커 버전으로 작성해서 저장 | ||
echo "version: '3.9' | ||
services: | ||
tweaver: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
environment: | ||
- TZ=Asia/Seoul | ||
ports: | ||
- 8080:8080 | ||
image: ${IMAGE_NAME} | ||
env_file: | ||
- ${CONTAINER_ENV_PATH} | ||
depends_on: | ||
- redis | ||
redis: | ||
image: redis | ||
command: redis-server --port 6379 | ||
container_name: tweaver-redis | ||
hostname: tweaver-redis | ||
labels: | ||
- "name=tweaver-redis" | ||
- "mode=standalone" | ||
ports: | ||
- 6379:6379 | ||
networks: | ||
default: | ||
external: true | ||
name: tweaver-network" > docker-compose.yml | ||
|
||
|
||
# 새로운 도커 컨테이너 실행 | ||
echo "IMAGE_NAME: $IMAGE_NAME 도커 실행" | ||
docker compose up -d $SERVICE_NAME |
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,11 @@ | ||
CONTAINER_NAME=tweaver-backend | ||
|
||
# 도커 컨테이너가 있는지 확인 (-a 옵션으로 정지된 컨테이너도 확인) | ||
RUNNING_CONTAINER_ID=$(docker ps -aq --filter "name=$CONTAINER_NAME") | ||
echo "실행중인 컨테이너 ID: $RUNNING_CONTAINER_ID" | ||
|
||
# 이전 도커 컨테이너 종료 | ||
if [ -n "$RUNNING_CONTAINER_ID" ]; then | ||
echo "이전 도커 컨테이너 종료 및 삭제합니다" | ||
docker stop $CONTAINER_NAME && docker rm $CONTAINER_NAME | ||
fi |