Skip to content

Commit

Permalink
[Chore] 도커컴포즈 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JIHYUN2EE committed Aug 29, 2024
1 parent ec24181 commit 27f7362
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,50 @@ jobs:
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker tag fitpet:latest ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
docker push ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
name: CI/CD Pipeline
deploy:
runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to EC2 via SSH
uses: appleboy/ssh-action@v0.1.5
env:
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
MYSQL_PASSWORD: ${{ secrets.PROD_MYSQL_PASSWORD }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
envs: DOCKER_IMAGE,MYSQL_PASSWORD
script: |
echo $${{ secrets.DOCKER_PASSWORD }} | docker login -u $${{ secrets.DOCKER_USERNAME }} --password-stdin
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
docker pull ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
cd /home/ubuntu
docker-compose -f docker-compose.yml up --build -d
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" > .env
echo "MYSQL_PASSWORD=${MYSQL_PASSWORD}" >> .env
docker-compose -f docker-compose.yml up --build -d
# deploy:
# runs-on: ubuntu-latest
# needs: build
#
# steps:
# - name: Deploy to EC2 via SSH
# uses: appleboy/ssh-action@v0.1.5
# with:
# host: ${{ secrets.EC2_HOST }}
# username: ${{ secrets.EC2_USERNAME }}
# key: ${{ secrets.EC2_SSH_KEY }}
# port: 22
# script: |
# echo $${{ secrets.DOCKER_PASSWORD }} | docker login -u $${{ secrets.DOCKER_USERNAME }} --password-stdin
#
#
# docker pull ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
#
# cd /home/ubuntu
# docker-compose -f docker-compose.yml up --build -d

5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '3'
services:
app:
image: $${ secrets.DOCKER_USERNAME }/fitpet:latest
image: ${DOCKER_IMAGE}
environment:
SPRING_PROFILES_ACTIVE: prod
PROD_MYSQL_HOST: fitpet.cb26miuuaa9v.ap-southeast-2.rds.amazonaws.com
PROD_MYSQL_DB_NAME: fitpet
PROD_MYSQL_USERNAME: admin
PROD_MYSQL_PASSWORD: 12345555
PROD_MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "8080:8080"
networks:
Expand All @@ -16,4 +16,3 @@ services:
networks:
app-network:
driver: bridge

0 comments on commit 27f7362

Please sign in to comment.