Compare commits

..

2 commits

Author SHA1 Message Date
fullsizemalt
c2c48faad8 chore: Make traefik network configurable and fix DB name
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
2025-12-21 00:10:14 -08:00
fullsizemalt
29c2033bca feat: Add CI/CD workflow for testing/production branch deployments
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
2025-12-20 23:49:36 -08:00
2 changed files with 49 additions and 8 deletions

View file

@ -0,0 +1,41 @@
name: Deploy Elmeg
on:
push:
branches:
- testing
- production
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set deployment target
id: target
run: |
if [ "${{ github.ref_name }}" = "testing" ]; then
echo "server=nexus-vector" >> $GITHUB_OUTPUT
echo "domain=elmeg.runfoo.run" >> $GITHUB_OUTPUT
elif [ "${{ github.ref_name }}" = "production" ]; then
echo "server=tangible-aacorn" >> $GITHUB_OUTPUT
echo "domain=elmeg.xyz" >> $GITHUB_OUTPUT
fi
- name: Deploy to ${{ steps.target.outputs.server }}
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ steps.target.outputs.server == 'nexus-vector' && '216.158.230.94' || '159.69.219.254' }}
username: root
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
cd /srv/containers/elmeg-demo
git fetch origin ${{ github.ref_name }}
git checkout ${{ github.ref_name }}
git reset --hard origin/${{ github.ref_name }}
docker compose build --no-cache
docker compose up -d
docker compose exec -T backend alembic upgrade head
echo "Deployed ${{ github.ref_name }} to ${{ steps.target.outputs.domain }}"

View file

@ -22,7 +22,7 @@ services:
retries: 3 retries: 3
networks: networks:
- elmeg - elmeg
- traefik - ${TRAEFIK_NETWORK:-traefik}
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.elmeg-backend.rule=(Host(`elmeg.runfoo.run`) || Host(`elmeg.xyz`)) && PathPrefix(`/api`)" - "traefik.http.routers.elmeg-backend.rule=(Host(`elmeg.runfoo.run`) || Host(`elmeg.xyz`)) && PathPrefix(`/api`)"
@ -33,7 +33,7 @@ services:
- "traefik.http.routers.elmeg-backend.middlewares=elmeg-strip" - "traefik.http.routers.elmeg-backend.middlewares=elmeg-strip"
- "traefik.http.routers.elmeg-backend.service=elmeg-backend-svc" - "traefik.http.routers.elmeg-backend.service=elmeg-backend-svc"
- "traefik.http.services.elmeg-backend-svc.loadbalancer.server.port=8000" - "traefik.http.services.elmeg-backend-svc.loadbalancer.server.port=8000"
- "traefik.docker.network=traefik" - "traefik.docker.network=${TRAEFIK_NETWORK:-traefik}"
# Direct routes for docs (no strip) # Direct routes for docs (no strip)
- "traefik.http.routers.elmeg-backend-docs.rule=(Host(`elmeg.runfoo.run`) || Host(`elmeg.xyz`)) && PathPrefix(`/docs`, `/openapi.json`)" - "traefik.http.routers.elmeg-backend-docs.rule=(Host(`elmeg.runfoo.run`) || Host(`elmeg.xyz`)) && PathPrefix(`/docs`, `/openapi.json`)"
- "traefik.http.routers.elmeg-backend-docs.entrypoints=websecure" - "traefik.http.routers.elmeg-backend-docs.entrypoints=websecure"
@ -51,14 +51,14 @@ services:
- ./frontend:/app - ./frontend:/app
- /app/node_modules - /app/node_modules
environment: environment:
- NEXT_PUBLIC_API_URL=https://elmeg.runfoo.run/api - NEXT_PUBLIC_API_URL=/api
- INTERNAL_API_URL=http://backend:8000 - INTERNAL_API_URL=http://backend:8000
depends_on: depends_on:
- backend - backend
restart: unless-stopped restart: unless-stopped
networks: networks:
- elmeg - elmeg
- traefik - ${TRAEFIK_NETWORK:-traefik}
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.elmeg-frontend.rule=(Host(`elmeg.runfoo.run`) || Host(`elmeg.xyz`)) && !PathPrefix(`/api`, `/docs`, `/openapi.json`)" - "traefik.http.routers.elmeg-frontend.rule=(Host(`elmeg.runfoo.run`) || Host(`elmeg.xyz`)) && !PathPrefix(`/api`, `/docs`, `/openapi.json`)"
@ -66,19 +66,19 @@ services:
- "traefik.http.routers.elmeg-frontend.tls.certresolver=letsencrypt" - "traefik.http.routers.elmeg-frontend.tls.certresolver=letsencrypt"
- "traefik.http.routers.elmeg-frontend.priority=50" - "traefik.http.routers.elmeg-frontend.priority=50"
- "traefik.http.services.elmeg-frontend.loadbalancer.server.port=3000" - "traefik.http.services.elmeg-frontend.loadbalancer.server.port=3000"
- "traefik.docker.network=traefik" - "traefik.docker.network=${TRAEFIK_NETWORK:-traefik}"
db: db:
image: postgres:15-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=elmeg - POSTGRES_USER=elmeg
- POSTGRES_PASSWORD=elmeg_password - POSTGRES_PASSWORD=elmeg_password
- POSTGRES_DB=elmeg_db - POSTGRES_DB=elmeg
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: [ "CMD-SHELL", "pg_isready -U elmeg" ] test: [ "CMD-SHELL", "pg_isready -U elmeg -d elmeg" ]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@ -92,5 +92,5 @@ volumes:
networks: networks:
elmeg: elmeg:
traefik: ${TRAEFIK_NETWORK:-traefik}:
external: true external: true