Skip to content
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

백엔드 CD 방식 변경 -> 도커 컴포즈 사용 #142

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,32 @@ jobs:
key: ${{ secrets.EC2_KEY }}

script: |
sudo docker kill ${{ secrets.PROJECT_NAME }}
sudo docker rm -f ${{ secrets.PROJECT_NAME }}
# 실행중인 서버 다운
sudo docker-compose down

# 백엔드 도커 이미지 삭제
sudo docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}

sudo docker run \
-e ADMIN_SECRET_KEY=${{ secrets.ADMIN_SECRET_KEY }} \
-e AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }} \
-e AWS_SECRET_KEY=${{ secrets.AWS_SECRET_KEY }} \
-e BASEBALL_API_KEY=${{ secrets.BASEBALL_API_KEY }} \
-e BASKETBALL_API_KEY=${{ secrets.BASKETBALL_API_KEY }} \
-e FOOTBALL_API_KEY=${{ secrets.FOOTBALL_API_KEY }} \
-e GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }} \
-e GOOGLE_API_SECRET=${{ secrets.GOOGLE_API_SECRET }} \
-e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \
-e KAKAO_API_KEY=${{ secrets.KAKAO_API_KEY }} \
-e NAVER_API_KEY=${{ secrets.NAVER_API_KEY }} \
-e NAVER_API_SECRET=${{ secrets.NAVER_API_SECRET }} \
-e RDS_USERNAME=${{ secrets.RDS_USERNAME }} \
-e RDS_PASSWORD=${{ secrets.RDS_PASSWORD }} \
-p ${{ secrets.PORT }}:${{ secrets.PORT }} \
--name ${{ secrets.PROJECT_NAME }} \
-d ${{ secrets.DOCKERHUB_USERNAME}}/${{ secrets.PROJECT_NAME }}

# 백엔드 환경변수 파일 삭제 및 생성
sudo rm .env_b
sudo touch .env_b

# 백엔드 환경변수 파일 작성
echo ADMIN_SECRET_KEY=${{ secrets.ADMIN_SECRET_KEY }} >> .env_b
echo AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }} >> .env_b
echo AWS_SECRET_KEY=${{ secrets.AWS_SECRET_KEY }} >> .env_b
echo BASEBALL_API_KEY=${{ secrets.BASEBALL_API_KEY }} >> .env_b
echo BASKETBALL_API_KEY=${{ secrets.BASKETBALL_API_KEY }} >> .env_b
echo FOOTBALL_API_KEY=${{ secrets.FOOTBALL_API_KEY }} >> .env_b
echo GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }} >> .env_b
echo GOOGLE_API_SECRET=${{ secrets.GOOGLE_API_SECRET }} >> .env_b
echo JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} >> .env_b
echo KAKAO_API_KEY=${{ secrets.KAKAO_API_KEY }} >> .env_b
echo NAVER_API_KEY=${{ secrets.NAVER_API_KEY }} >> .env_b
echo NAVER_API_SECRET=${{ secrets.NAVER_API_SECRET }} >> .env_b
echo RDS_USERNAME=${{ secrets.RDS_USERNAME }} >> .env_b
echo RDS_PASSWORD=${{ secrets.RDS_PASSWORD }} >> .env_b
echo ${{ secrets.PORT }}:${{ secrets.PORT }} >> .env_b

# 백엔드 도커 이미지 pull 및 도커 컴포즈 실행
sudo docker-compose up -d
Loading