-
Notifications
You must be signed in to change notification settings - Fork 3
Update: 여러 프로젝트 실행 충돌을 방지하기 위한 CI/CD 스크립트 업데이트 #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,35 +1,63 @@ | ||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||
| cd /home/ubuntu/gdgoc-fe-app | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Docker & Docker Compose가 설치되어 있는지 확인 | ||||||||||||||||||||||||||||||||
| # Set the application directory | ||||||||||||||||||||||||||||||||
| APP_DIR="/home/ubuntu/gdgocinha-fe" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Create application directory if it doesn't exist | ||||||||||||||||||||||||||||||||
| mkdir -p $APP_DIR | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Move to application directory | ||||||||||||||||||||||||||||||||
| cd $APP_DIR | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Docker & Docker Compose installation check and setup | ||||||||||||||||||||||||||||||||
| if ! [ -x "$(command -v docker)" ]; then | ||||||||||||||||||||||||||||||||
| echo "Docker가 설치되어 있지 않습니다. 설치 중..." | ||||||||||||||||||||||||||||||||
| echo "Installing Docker..." | ||||||||||||||||||||||||||||||||
| sudo apt update | ||||||||||||||||||||||||||||||||
| sudo apt install -y docker.io | ||||||||||||||||||||||||||||||||
| sudo systemctl start docker | ||||||||||||||||||||||||||||||||
| sudo systemctl enable docker | ||||||||||||||||||||||||||||||||
| echo "Docker 설치 완료" | ||||||||||||||||||||||||||||||||
| sudo usermod -aG docker ubuntu | ||||||||||||||||||||||||||||||||
| echo "Docker installation completed" | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if ! [ -x "$(command -v docker-compose)" ]; then | ||||||||||||||||||||||||||||||||
| echo "Docker Compose가 설치되어 있지 않습니다. 설치 중..." | ||||||||||||||||||||||||||||||||
| echo "Installing Docker Compose..." | ||||||||||||||||||||||||||||||||
| sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||||||||||||||||||||||||||||||||
| sudo chmod +x /usr/local/bin/docker-compose | ||||||||||||||||||||||||||||||||
| echo "Docker Compose 설치 완료" | ||||||||||||||||||||||||||||||||
| echo "Docker Compose installation completed" | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # 기존 컨테이너 중지 및 삭제 | ||||||||||||||||||||||||||||||||
| docker-compose down | ||||||||||||||||||||||||||||||||
| # Stop and remove existing containers | ||||||||||||||||||||||||||||||||
| echo "Stopping existing containers..." | ||||||||||||||||||||||||||||||||
| docker-compose down || true | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # 사용되지 않는 컨테이너, 이미지, 네트워크, 볼륨 정리 | ||||||||||||||||||||||||||||||||
| # Clean up unused Docker resources | ||||||||||||||||||||||||||||||||
| echo "Cleaning up Docker resources..." | ||||||||||||||||||||||||||||||||
| docker system prune -af | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # 불필요한 Docker 볼륨도 정리 (옵션) | ||||||||||||||||||||||||||||||||
| docker volume prune -f | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # 최신 이미지 가져오기 | ||||||||||||||||||||||||||||||||
| export $(grep -v '^#' .env | xargs) | ||||||||||||||||||||||||||||||||
| docker pull ${DOCKER_HUB_USERNAME}/gdgoc-fe-app:latest | ||||||||||||||||||||||||||||||||
| # Load environment variables | ||||||||||||||||||||||||||||||||
| if [ -f .env ]; then | ||||||||||||||||||||||||||||||||
| echo "Loading environment variables..." | ||||||||||||||||||||||||||||||||
| export $(grep -v '^#' .env | xargs) | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| echo "Error: .env file not found" | ||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Pull latest image | ||||||||||||||||||||||||||||||||
| echo "Pulling latest Docker image..." | ||||||||||||||||||||||||||||||||
| docker pull ${DOCKER_HUB_USERNAME}/gdgocinha-fe:latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # 컨테이너 실행 | ||||||||||||||||||||||||||||||||
| # Start containers | ||||||||||||||||||||||||||||||||
| echo "Starting containers..." | ||||||||||||||||||||||||||||||||
| docker-compose --env-file .env up -d | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Verify deployment | ||||||||||||||||||||||||||||||||
| echo "Verifying deployment..." | ||||||||||||||||||||||||||||||||
| if [ $(docker ps -q -f name=gdgocinha-fe | wc -l) -eq 1 ]; then | ||||||||||||||||||||||||||||||||
| echo "Deployment successful!" | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| echo "Deployment failed!" | ||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+61
|
||||||||||||||||||||||||||||||||
| if [ $(docker ps -q -f name=gdgocinha-fe | wc -l) -eq 1 ]; then | |
| echo "Deployment successful!" | |
| else | |
| echo "Deployment failed!" | |
| CONTAINER_ID=$(docker ps -q -f name=gdgocinha-fe) | |
| if [ -n "$CONTAINER_ID" ]; then | |
| HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_ID 2>/dev/null) | |
| if [ "$HEALTH_STATUS" == "healthy" ]; then | |
| echo "Deployment successful!" | |
| else | |
| echo "Deployment failed: Container is not healthy (status: $HEALTH_STATUS)" | |
| exit 1 | |
| fi | |
| else | |
| echo "Deployment failed: Container not found" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying the .env file into the production image may expose sensitive configuration details. Consider injecting environment variables externally rather than including the .env file in the image.