fix: adding db recovery practices (bye bye db)
Some checks failed
Security Tests / security-non-db (push) Successful in 18s
Security Tests / security-db (push) Successful in 23s
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2026-03-02 11:16:52 -06:00
parent 301b3f8967
commit d9df9b0fe4
11 changed files with 409 additions and 15 deletions

View File

@@ -27,6 +27,8 @@ jobs:
- name: Deploy with Docker Compose
run: |
set -euo pipefail
# Deploy directory
APP_DIR=/opt/skymoney
mkdir -p $APP_DIR
@@ -47,14 +49,29 @@ jobs:
cd $APP_DIR
# Keep a stable compose project name to avoid accidental new resource names
export COMPOSE_PROJECT_NAME=skymoney
# Validate migration target before touching containers
export EXPECTED_PROD_DB_HOST="${EXPECTED_PROD_DB_HOST:-postgres}"
export EXPECTED_PROD_DB_NAME="${EXPECTED_PROD_DB_NAME:-skymoney}"
./scripts/validate-prod-db-target.sh
# Build and start all services
sudo docker-compose up -d --build
sudo -E docker-compose up -d --build
# Wait for database to be ready
sleep 10
# Mandatory pre-migration backup
BACKUP_ENFORCE_TARGET_CHECK=1 \
EXPECTED_PROD_DB_HOST="$EXPECTED_PROD_DB_HOST" \
EXPECTED_PROD_DB_NAME="$EXPECTED_PROD_DB_NAME" \
BACKUP_DIR=/opt/skymoney/backups \
./scripts/backup.sh
# Run Prisma migrations inside the API container
sudo docker-compose exec -T api npx prisma migrate deploy
sudo -E docker-compose exec -T api npx prisma migrate deploy
- name: Reload Nginx
run: sudo systemctl reload nginx