Skip to content

Commit

Permalink
feat(cd): push and pull from dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jun 30, 2024
1 parent bd0865a commit a97472e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
48 changes: 42 additions & 6 deletions .github/workflows/deploy-ntfy-do.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,47 @@ on:
paths-ignore:
- "**.md"
- "LICENSE"
- "LICENSE.txt"
- "frontend/**"

jobs:
dockerhub:
name: Publish Docker Image(s) to Dockerhub
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build & Push Naarad
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/naarad:latest

- name: Build & Push Naarad API
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/naarad-api:latest

push:
name: Push Stage
name: Push Code Stage
needs: dockerhub
runs-on: ubuntu-latest

steps:
Expand All @@ -31,13 +67,13 @@ jobs:
sudo git fetch origin
sudo git reset --hard origin/main
build:
name: Build Stage
pull:
name: Pull Image Stage
needs: push
runs-on: ubuntu-latest

steps:
- name: Build the latest container(s)
- name: Pull the latest images(s)
uses: appleboy/ssh-action@master
env:
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
Expand All @@ -50,11 +86,11 @@ jobs:
script_stop: true
script: |
cd "${PROJECT_DIR}/"
sudo docker compose build
sudo docker compose pull
deploy:
name: Deploy Stage
needs: [push, build]
needs: pull
runs-on: ubuntu-latest

steps:
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
services:
naarad:
image: metakgporg/naarad
container_name: naarad
build:
context: .
dockerfile: Dockerfile
Expand Down Expand Up @@ -29,7 +31,8 @@ services:
restart: unless-stopped

naarad-api:
image: naarad-api
image: metakgporg/naarad-api
container_name: naarad-api
build:
context: backend/
dockerfile: Dockerfile
Expand Down

0 comments on commit a97472e

Please sign in to comment.