-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56a7bc8
commit 107fe19
Showing
1 changed file
with
57 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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,68 +1,68 @@ | ||
name: Build and Push Docker Images | ||
# name: Build and Push Docker Images | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check Out Repo | ||
uses: actions/checkout@v2 | ||
# jobs: | ||
# build-and-push: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Check Out Repo | ||
# uses: actions/checkout@v2 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
# - name: Log in to Docker Hub | ||
# uses: docker/login-action@v1 | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and Push DB Handler Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile.db | ||
push: true | ||
tags: dhanush2313/cicd:db-latest | ||
# - name: Build and Push DB Handler Image | ||
# uses: docker/build-push-action@v2 | ||
# with: | ||
# context: . | ||
# file: ./docker/Dockerfile.db | ||
# push: true | ||
# tags: dhanush2313/cicd:db-latest | ||
|
||
- name: Build and Push User App Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile.userapp | ||
push: true | ||
tags: dhanush2313/cicd:user-app-latest | ||
# - name: Build and Push User App Image | ||
# uses: docker/build-push-action@v2 | ||
# with: | ||
# context: . | ||
# file: ./docker/Dockerfile.userapp | ||
# push: true | ||
# tags: dhanush2313/cicd:user-app-latest | ||
|
||
- name: Build and Push Webhook Handler Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile.webhook | ||
push: true | ||
tags: dhanush2313/cicd:webhook-handler-latest | ||
# - name: Build and Push Webhook Handler Image | ||
# uses: docker/build-push-action@v2 | ||
# with: | ||
# context: . | ||
# file: ./docker/Dockerfile.webhook | ||
# push: true | ||
# tags: dhanush2313/cicd:webhook-handler-latest | ||
|
||
- name: Deploy to EC2 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
script: | | ||
sudo docker network create my_network || true | ||
# - name: Deploy to EC2 | ||
# uses: appleboy/ssh-action@master | ||
# with: | ||
# host: ${{ secrets.SSH_HOST }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# key: ${{ secrets.SSH_KEY }} | ||
# script: | | ||
# sudo docker network create my_network || true | ||
|
||
sudo docker pull dhanush2313/cicd:db-latest | ||
sudo docker pull dhanush2313/cicd:user-app-latest | ||
sudo docker pull dhanush2313/cicd:webhook-handler-latest | ||
# sudo docker pull dhanush2313/cicd:db-latest | ||
# sudo docker pull dhanush2313/cicd:user-app-latest | ||
# sudo docker pull dhanush2313/cicd:webhook-handler-latest | ||
|
||
sudo docker stop db || true | ||
sudo docker rm db || true | ||
sudo docker run -d --name db --network my_network -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=bruh123 -e POSTGRES_DB=postgres -p 5432:5432 dhanush2313/cicd:db-latest | ||
# sudo docker stop db || true | ||
# sudo docker rm db || true | ||
# sudo docker run -d --name db --network my_network -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=bruh123 -e POSTGRES_DB=postgres -p 5432:5432 dhanush2313/cicd:db-latest | ||
|
||
sudo docker stop user-app || true | ||
sudo docker rm user-app || true | ||
sudo docker run -d --name user-app --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e WEBHOOK_URL=http://webhook-handler:3003 -p 3001:3001 dhanush2313/cicd:user-app-latest | ||
# sudo docker stop user-app || true | ||
# sudo docker rm user-app || true | ||
# sudo docker run -d --name user-app --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e WEBHOOK_URL=http://webhook-handler:3003 -p 3001:3001 dhanush2313/cicd:user-app-latest | ||
|
||
sudo docker stop webhook-handler || true | ||
sudo docker rm webhook-handler || true | ||
sudo docker run -d --name webhook-handler --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e PORT=3003 -p 3003:3003 dhanush2313/cicd:webhook-handler-latest | ||
# sudo docker stop webhook-handler || true | ||
# sudo docker rm webhook-handler || true | ||
# sudo docker run -d --name webhook-handler --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e PORT=3003 -p 3003:3003 dhanush2313/cicd:webhook-handler-latest |