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 --listBuild the assets:
See the Compiling assets section.
just dev-setupThe development server can be run locally, as described below, or in docker.
just runjust dev-resetAccess at http://localhost:8000
To add a report in local development:
- Log into the admin with username
adminand passwordadmin. - Under
Reportssection, clickReports. - Click
Add Reportand complete the form. - In the
Report file detailssection, enter a valid Job Server URL(example URL). - Set the category to
Reportsfor a standard report, orArchivefor an archived report. - If the
Archivecategory does not exist, go toCategoriesin theReportssection and add it first.
# 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.
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 = Trueinreports/settings.py - Open a terminal and run Django with
just run - Open a new terminal tab or window
- Run
npm run devto 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
.envfile 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-serveRun the tests in docker
just docker-testTo 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 --pdbRun a command in the dev docker containter
just docker-run <command>- Log into the
opensafely-readonlyGitHub 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>