-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dev docker config and deploy workflow
- Loading branch information
1 parent
35df6fa
commit 7d083d8
Showing
3 changed files
with
126 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Build and deploy dev | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
env: | ||
tag: dev | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build, tag and push backend | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ./apps/backend/Dockerfile | ||
tags: ${{ vars.DOCKERHUB_USERNAME }}/dundring-backend:${{ env.tag }} | ||
push: true | ||
|
||
- name: Build, tag and push frontend | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ./apps/frontend/Dockerfile | ||
push: true | ||
tags: ${{ vars.DOCKERHUB_USERNAME }}/dundring-frontend:${{ env.tag }} | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: dev | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Add docker compose file to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
source: docker/dev/docker-compose.yaml | ||
target: dev | ||
strip_components: 2 | ||
|
||
- name: Start the containers with Docker Compose | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
|
||
script: | | ||
cd dev | ||
docker-compose pull | ||
DB_USERNAME=${{ DB_USERNAME }} \ | ||
DB_PASSWORD=${{ DB_PASSWORD }} \ | ||
CLOUDFLARE_DNS_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }} \ | ||
MAIL_HOST=${{ secrets.MAIL_HOST }} \ | ||
MAIL_PORT=${{ secrets.MAIL_PORT }} \ | ||
MAIL_USER=${{ secrets.MAIL_USER }} \ | ||
MAIL_PASSWORD='${{ secrets.MAIL_PASSWORD }}' \ | ||
TOKEN_SECRET=${{ secrets.TOKEN_SECRET }} \ | ||
docker-compose up -d |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
version: '3.7' | ||
services: | ||
postgres: | ||
image: postgres:16.1-alpine | ||
container_name: postgres-dev | ||
restart: always | ||
environment: | ||
POSTGRES_USER: ${DB_USERNAME} | ||
POSTGRES_PASSWORD: ${DB_PASSWORD} | ||
networks: | ||
- dundring | ||
volumes: | ||
- ~/dev-data:/var/lib/postgresql/data | ||
|
||
backend: | ||
image: sivertschou/dundring-backend:dev | ||
container_name: backend-dev | ||
restart: always | ||
environment: | ||
- DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/dundring | ||
- MAIL_PORT=${MAIL_PORT} | ||
- MAIL_HOST=${MAIL_HOST} | ||
- MAIL_USER=${MAIL_USER} | ||
- MAIL_PASSWORD=${MAIL_PASSWORD} | ||
- TOKEN_SECRET=${TOKEN_SECRET} | ||
networks: | ||
- caddy | ||
- dundring | ||
labels: | ||
caddy: dev.dundring.com | ||
caddy.reverse_proxy: '/api* {{upstreams 8080}}' | ||
caddy.tls.dns: 'cloudflare ${CLOUDFLARE_DNS_API_TOKEN}' | ||
|
||
frontend: | ||
image: sivertschou/dundring-frontend:dev | ||
container_name: frontend-dev | ||
restart: always | ||
networks: | ||
- caddy | ||
labels: | ||
caddy: dev.dundring.com | ||
caddy.reverse_proxy: '{{upstreams 80}}' | ||
caddy.tls.dns: 'cloudflare ${CLOUDFLARE_DNS_API_TOKEN}' | ||
|
||
networks: | ||
caddy: | ||
external: true | ||
dundring: |