Skip to content

Deployment

Docker-based deployment with automated scripts. Supports standard, parallel, and incremental strategies.

Deployment Methods

Standard

Stops current container, starts new one. Causes brief downtime.

./fast-deploy.sh --migrate

Parallel (Reduced Downtime)

Starts new container alongside existing one, switches traffic when ready.

./fast-deploy.sh --parallel --migrate

Incremental (Faster)

Only updates what changed.

./fast-deploy.sh --incremental --migrate
# Skip resource copy (use cache):
./fast-deploy.sh --incremental --skip-resources --migrate

Database Handling

All deployments preserve the production database by default.

Run Migrations (preserve data)

./fast-deploy.sh --migrate

Backup

Automatic backup runs before every deployment.

# Manual backup:
./fast-deploy.sh --backup

# Restore from latest:
./fast-deploy.sh --restore

# Restore from specific file:
./fast-deploy.sh --restore /path/to/backup.sql

Reset Database

Danger

This deletes ALL production data. Requires explicit confirmation.

./fast-deploy.sh --reset-db

Health Checks & Rollback

After deployment, a health check verifies the app is running. Auto-rollback on failure.

./fast-deploy.sh --migrate                            # default: health check enabled
./fast-deploy.sh --migrate --skip-health-check        # skip (not recommended)
./fast-deploy.sh --migrate --health-endpoint /api/healthcheck

CI/CD (GitHub Actions)

Workflow in .github/workflows/deploy.yml:

  1. Build & test on push to main
  2. Auto-deploy to staging after successful build
  3. Deploy to production on release or manual trigger
  4. Auto-backup before deployment
  5. Health check with auto-rollback

Manual Trigger

  1. GitHub → Actions → "Deploy NFC Connect"
  2. Click "Run workflow"
  3. Choose environment, method, options

Deployment Files

File Purpose
deploy.py Main deployment script
instance_up_with_resources.py Start/configure instances
instance_down_with_resources.py Stop instances + resource backup
fast-deploy.sh User-friendly shell wrapper

Troubleshooting

SSH issues: Check DigitalOcean access token, droplet name in properties.yml, SSH access for root user.

Migration failures: Check migration script, verify schema matches expected state, check error logs, restore from backup if needed. Never use --reset-db to fix migration failures without backing up first.

Health check failures: Check health endpoint, verify app logs, ensure container is running, check HTTP/HTTPS accessibility.