Skip to content

Commit

Permalink
chore: 배포 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
shdhkim committed Dec 21, 2024
1 parent 6fc9eb1 commit 5a28370
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/flask-app:latest

# 6. EC2로 배포
- name: Deploy to EC2
# 6. EC2로 배포 (Docker Pull 방식)
- name: Deploy to EC2 via Docker Pull
env:
HOST: 3.39.237.18 # EC2 퍼블릭 IP 또는 도메인
USER: ${{ secrets.DEPLOY_USER }} # EC2 SSH 사용자 이름
HOST: 3.39.237.18 # EC2 퍼블릭 IP
USER: ${{ secrets.DEPLOY_USER }} # EC2 사용자 이름
KEY: ${{ secrets.DEPLOY_KEY }} # SSH 개인 키
IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/flask-app:latest
run: |
Expand All @@ -56,7 +56,7 @@ jobs:
echo "Adding $HOST to known_hosts"
ssh-keyscan -H $HOST >> ~/.ssh/known_hosts || exit 1
# EC2 접속 및 Docker Compose 실행
# EC2 접속 및 Docker 실행
ssh -i deploy_key.pem $USER@$HOST <<EOF
# Docker 설치 확인 및 설치
if ! [ -x "$(command -v docker)" ]; then
Expand All @@ -65,25 +65,12 @@ jobs:
sudo service docker start
fi
# Docker Compose 설치 확인 및 설치
if ! [ -x "$(command -v docker-compose)" ]; then
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
fi
# 프로젝트 디렉터리로 이동 및 업데이트
mkdir -p ~/flask-milvus-app
cd ~/flask-milvus-app
# 최신 코드 가져오기
if [ -d .git ]; then
git pull origin main
else
git clone https://github.com/yourusername/your-repo.git .
fi
# Docker Hub 로그인 (필요한 경우)
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# Docker Compose 실행
docker-compose down
docker-compose pull
docker-compose up -d --build
# Docker 이미지 Pull 및 컨테이너 실행
sudo docker stop flask-app || true
sudo docker rm flask-app || true
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/flask-app:latest
sudo docker run -d -p 80:80 --name flask-app ${{ secrets.DOCKER_USERNAME }}/flask-app:latest
EOF

0 comments on commit 5a28370

Please sign in to comment.