elmeg-demo/.agent/workflows/deploy.md

1.9 KiB

description
how to deploy elmeg changes safely

Elmeg Safe Deployment

CRITICAL: Never wipe the database

When deploying changes to elmeg, ONLY rebuild the backend and frontend containers. The database must NEVER be rebuilt or recreated.

Safe deployment command

Production (elmeg.xyz) - tangible-aacorn

# turbo
ssh tangible-aacorn "cd /srv/containers/elmeg-demo && git pull && docker compose up -d --build --no-deps backend frontend"

Staging (elmeg.runfoo.run) - nexus-vector

# turbo
ssh nexus-vector "cd /srv/containers/elmeg-demo && git pull && docker compose up -d --build --no-deps backend frontend"

DANGEROUS - Do NOT use these commands

# These will WIPE THE DATABASE:
docker compose up -d --build          # Rebuilds ALL containers including db
docker compose down && docker compose up -d  # Recreates all containers
docker compose up -d --force-recreate  # Force recreates all
# turbo
ssh nexus-vector "docker exec elmeg-demo-db-1 pg_dump -U elmeg elmeg > /srv/containers/elmeg-demo/backup-\$(date +%Y%m%d-%H%M%S).sql"

Restore from backup if needed

ssh nexus-vector "cat /srv/containers/elmeg-demo/backup-YYYYMMDD-HHMMSS.sql | docker exec -i elmeg-demo-db-1 psql -U elmeg elmeg"

Data Import (Recovery)

If the database is wiped or fresh, use the Smart Import script to populate shows and setlists. This script is memory-optimized and checks for infinite loops.

Production (tangible-aacorn)

ssh tangible-aacorn "docker exec elmeg-backend-1 python import_setlists_smart.py"

Staging (nexus-vector)

ssh nexus-vector "docker exec elmeg-demo-backend-1 python import_setlists_smart.py"

Git Configuration (Production)

To ensure git pull works correctly on production:

# On nexus-vector
cd /srv/containers/elmeg-demo
git branch --set-upstream-to=origin/main main