Skip to content
FEMNET

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. 1

    Connect and check for local changes

    SSH to the VPS and run:

    cd /opt/femnet-lms-drf

    git status --short

    It should print nothing. Investigate any local changes before pulling.

  2. 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. 3

    Pull the new code

    git pull origin main, then add any new settings to .env that the release notes mention.

  4. 4

    Rebuild, migrate and restart

    docker compose build

    docker compose run --rm drf python manage.py migrate

    docker compose run --rm drf python manage.py collectstatic --noinput

    docker compose up -d --force-recreate drf celery_worker celery_beat

  5. 5

    Check it is healthy

    curl -i https://femnet-api.duckdns.org/health/ should return 200. Check docker compose logs --tail=50 drf for 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).

Related how-tos