Run the site#

The site runs as one container: nginx serves the static files and passes the rest to gunicorn. The image is ghcr.io/pycalendar/dashboard.pycal.org; the tag latest follows the branch main, and it is only pushed when all tests pass.

  1. Copy the example settings and the compose file:

    curl -O https://raw.githubusercontent.com/PyCalendar/dashboard.pycal.org/main/docker-compose.yml
    curl -o .env https://raw.githubusercontent.com/PyCalendar/dashboard.pycal.org/main/.env.example
    
  2. Edit .env: at least SITE_URL, ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS. All settings are in Settings.

  3. Start it:

    docker compose up -d
    docker compose logs dashboard
    
  4. The log says that the site has no GitHub App and no OAuth app yet, and shows the setup code:

    This site has no GitHub App yet. Register it on https://dashboard.pycal.org/setup/github-app/ with the setup code 3f9a-0c41-77d2
    Nobody can sign in: this site has no OAuth app. Enter it on https://dashboard.pycal.org/setup/oauth-app/ with the setup code 3f9a-0c41-77d2
    

    Set up both as Register the GitHub App and the OAuth app describes, then install the GitHub App, see Install the GitHub App.

The volume ./data holds the SQLite database, the generated secret key and the credentials of the GitHub App and the OAuth app. Back it up.

The container#

At every start, the container migrates the database and says in the log what is missing (manage.py prepare).

The health check of the container calls /health/ with the first host of ALLOWED_HOSTS. While the site starts, nginx answers with a page that says so.

Update#

docker compose pull && docker compose up -d

Deploy with Sencho#

CI deploys every push of main after the image was pushed: it asks Sencho to update the stack, then checks the live site. The job Deploy to Sencho fails until the deployment exists:

  1. Create the stack in Sencho, named dashboard-pycal, with docker-compose.yml, its .env and the volume ./data.

  2. In the repository on GitHub, create the environment dashboard.pycal.org (Settings → Environments) with the secret SENCHO_TOKEN, a token of the API of Sencho. A stack of another name is the repository variable SENCHO_STACK.

  3. Make the package ghcr.io/pycalendar/dashboard.pycal.org public, or give Sencho access to it.

Sencho answers 409 while the stack deploys already and 5xx for passing errors: the job tries ten times, 30 seconds apart.

Check the live site#

After each deployment, the job Check the live site runs:

make check-live                                     # https://dashboard.pycal.org
LIVE_URL=https://dashboard.example.org make check-live

It waits while the site starts (up to LIVE_WAIT seconds, 600 by default), follows the links of the public pages as a visitor, reads their JSON and checks that errors get their pages: a missing page is 404, not 500, the account asks to sign in and the webhook refuses unsigned deliveries. It sends nothing but one unsigned webhook, which the site refuses and logs.