Deployment uses dokku
and requires the environment variables defined in dotenv-sample
.
It is deployed to our dokku3
instance (see dokku docs).
# macOS
brew install just
# Linux
# Install from https://github.com/casey/just/releases
# Add completion for your shell. E.g. for bash:
source <(just --completions bash)
# Show all available commands
just # shortcut for just --list
Build the assets:
See the Compiling assets section.
just dev-setup
The development server can be run locally, as described below, or in docker.
just run
just dev-reset
Access at http://localhost:8000
# all tests and coverage
just test
# run specific test with usual pytest syntax
just test <path/to/test>::<test name>
This project uses Vite, a modern build tool and development server, to build the frontend assets. Vite integrates into the Django project using the django-vite package.
Vite works by compiling JavaScript files, and outputs a manifest file, the JavaScript files, and any included assets such as stylesheets or images.
Vite adds all JavaScript files to the page using ES6 Module syntax. For legacy browsers, this project is utilising the Vite Legacy Plugin to provide a fallback using the module/nomodule pattern.
For styling this project uses Scss to compile the stylesheets, and then PostCSS for post-processing.
Vite has a built-in development server which will serve the assets and reload them on save.
To run the Vite server locally, after completing the local dev env setup:
- Set
ASSETS_DEV_MODE = True
inreports/settings.py
- Open a terminal and run Django with
just run
- Open a new terminal tab or window
- Run
npm run dev
to start the vite server - Any changes you make in the
assets/
folder will now be updated without requiring a page refresh
This will start the Vite dev server at localhost:3000 and inject the relevant scripts into the Django templates.
To view the compiled assets:
- Update the
.env
file toASSETS_DEV_MODE=False
- Run
just assets-rebuild
Vite builds the assets and outputs them to the assets/dist
folder.
Django Staticfiles app then collects the files and places them in the staticfiles/assets
folder, with the manifest file located at staticfiles/manifest.json
.
Run a local development server in docker:
just docker-serve
Run the tests in docker
just docker-test
To run named test(s) or pass additional args, pass paths and args as you normally would to pytest:
just docker-test tests/reports/test_models.py::test_report_model_validation -k some-mark --pdb
Run a command in the dev docker containter
just docker-run <command>
- Log into the
opensafely-readonly
GitHub account (credentials are in Bitwarden). - Got to the Personal access tokens (classic) page.
- Click on
reports-private-repo-token
. - Click "Regenerate token".
- Set the expiry to 90 days.
- Copy the new token.
- ssh into
dokku3.ebmdatalab.net
- Run:
dokku config:set reports GITHUB_TOKEN=<the new token>