Skip to content

Commit

Permalink
Update ci/cd pipeline to use docker compose instead of docker
Browse files Browse the repository at this point in the history
  • Loading branch information
BYEONGRYEOL authored Apr 6, 2024
1 parent 141ab9f commit d3b4865
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions .github/workflows/cicd-ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,38 @@ jobs:
echo "${{ secrets.APPLICATION_DEPLOY }}" > ./application-deploy.yml
shell: bash


# gradle build
- name: Build with Gradle
run: ./gradlew build

- name: Upload docker compose file to deploy server
if: contains(github.ref, 'main')
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST_DEPLOY }}
username: ubuntu
key: ${{ secrets.EC2_KEYPAIR }}
port: 22
source: "./docker/deploy/*"
target: "/home/ubuntu/workspace/docker/"

- name: Upload docker compose file to dev server
if: contains(github.ref, 'dev')
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST_DEV }}
username: ubuntu
key: ${{ secrets.EC2_KEYPAIR }}
port: 22
source: "./docker/dev/*"
target: "/home/ubuntu/workspace/docker/"

# docker build & push to deploy server
- name: Docker build & push to deploy
if: contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile-deploy -t ${{ secrets.DOCKER_USERNAME }}/genti-deploy .
docker push ${{ secrets.DOCKER_USERNAME }}/genti-deploy
Expand All @@ -74,10 +98,10 @@ jobs:
docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/genti-dev .
docker push ${{ secrets.DOCKER_USERNAME }}/genti-dev
## deploy to production
- name: Deploy to prod
## deploy to deploy server
- name: Deploy to deploy server
uses: appleboy/ssh-action@master
id: deploy-prod
id: deploy-deploy
if: contains(github.ref, 'main')
with:
host: ${{ secrets.HOST_DEPLOY }} # EC2 퍼블릭 IPv4 DNS
Expand All @@ -86,12 +110,14 @@ jobs:
envs: GITHUB_SHA
script: |
sudo docker ps
sudo cd /home/ubuntu/workspace/docker
sudo pwd
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/genti-deploy
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/genti-deploy
sudo docker compose up -d
sudo docker image prune -f
## deploy to develop
- name: Deploy to dev
## deploy to dev server
- name: Deploy to dev server
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'develop')
Expand All @@ -103,6 +129,8 @@ jobs:
key: ${{ secrets.EC2_KEYPAIR }}
script: |
sudo docker ps
sudo cd /home/ubuntu/workspace/docker
sudo pwd
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/genti-deploy
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/genti-deploy
sudo docker compose up -d
sudo docker image prune -f

0 comments on commit d3b4865

Please sign in to comment.