Deploy or update the backend
Pull, rebuild, migrate and restart the API on the VPS.
IT teamDone in: Server5 steps
Before you start
- SSH access to the VPS
- Docker and Docker Compose on the VPS
- 1
Connect and check for local changes
SSH to the VPS and run:
cd /opt/femnet-lms-drfgit status --shortIt should print nothing. Investigate any local changes before pulling.
- 2
Back up the database
docker compose exec postgres pg_dump -U femnet -d femnet > dumps/pre-deploy-$(date +%Y%m%d%H%M%S).sql - 3
Pull the new code
git pull origin main, then add any new settings to.envthat the release notes mention. - 4
Rebuild, migrate and restart
docker compose builddocker compose run --rm drf python manage.py migratedocker compose run --rm drf python manage.py collectstatic --noinputdocker compose up -d --force-recreate drf celery_worker celery_beat - 5
Check it is healthy
curl -i https://femnet-api.duckdns.org/health/should return 200. Checkdocker compose logs --tail=50 drffor errors, then sign in to the hub and learner app.
If something goes wrong
- Migrations fail.
- Do not restart the old containers on a half-migrated database. Read the error, and restore the backup you just took if needed (see Back up and restore data).
