Skip to content

Commit

Permalink
feat(cd): publish and pull from dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jul 1, 2024
1 parent efef9c5 commit 3867937
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 28 deletions.
54 changes: 48 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,50 @@ on:
- ".github/workflows/deploy.yaml"

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: Cache Docker layers for Heimdall
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-heimdall
key: ${{ runner.os }}-buildx-heimdall-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-heimdall-
- name: Build & Push Heimdall
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/heimdall:latest
cache-from: type=local,src=/tmp/.buildx-cache-heimdall
cache-to: type=local,dest=/tmp/.buildx-cache-heimdall-new,mode=max

- name: Move Heimdall cache
run: |
rm -rf /tmp/.buildx-cache-heimdall
mv /tmp/.buildx-cache-heimdall-new /tmp/.buildx-cache-heimdall
push:
name: Push Stage
name: Push Code Stage
needs: dockerhub
runs-on: ubuntu-latest

steps:
Expand All @@ -35,13 +77,13 @@ jobs:
sudo git fetch origin
sudo git reset --hard origin/master
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 @@ -54,11 +96,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
46 changes: 24 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
services:
heimdall:
build: "."
restart: always
environment:
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
- OTP_VALIDITY_PERIOD=${OTP_VALIDITY_PERIOD}
- RESEND_OTP_COOLDOWN=${RESEND_OTP_COOLDOWN}
- JWT_EXPIRY_DAYS=${JWT_EXPIRY_DAYS}
heimdall:
image: metakgporg/heimdall
container_name: heimdall
build: .
restart: always
environment:
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
- OTP_VALIDITY_PERIOD=${OTP_VALIDITY_PERIOD}
- RESEND_OTP_COOLDOWN=${RESEND_OTP_COOLDOWN}
- JWT_EXPIRY_DAYS=${JWT_EXPIRY_DAYS}

networks:
metaploy-network:
aliases:
- heimdall
volumes:
- nginx-config-volume:/etc/nginx/sites-enabled
- ./credentials.json:/credentials.json
- ./token.json:/token.json
networks:
metaploy-network:
aliases:
- heimdall
volumes:
- nginx-config-volume:/etc/nginx/sites-enabled
- ./credentials.json:/credentials.json
- ./token.json:/token.json

networks:
metaploy-network:
external: true
name: metaploy-network
metaploy-network:
external: true
name: metaploy-network

volumes:
nginx-config-volume:
external: true
name: metaploy-nginx-config-volume
nginx-config-volume:
external: true
name: metaploy-nginx-config-volume

0 comments on commit 3867937

Please sign in to comment.