Skip to content

Setup your Dev environment¤

The following documentation assume your system meet the prerequisites.

Clone the repository¤

git clone git@github.com:ManoManoTech/firefighter-incident.git
cd firefighter-incident

Load ASDF/Mise/Direnv (optional)¤

If you use ASDF, Mise (previously rtx) or Direnv, you can load the environment with:

asdf install
# or
mise install
# then
direnv allow

Install dependencies with PDM¤

We assume you have pdm in your path. If you have installed it with pipx, you can use pipx run pdm instead.

pdm install

A new virtualenv will be created in .venv and dependencies will be installed.

Activate your venv¤

While you can use pdm run to run commands, you can also activate your venv with:

source .venv/bin/activate

Install pre-commit hooks (optional)¤

pre-commit install

Set your .env¤

First, copy the .env.example to .env and edit it.

The first part of the .env is just your choice of local development, and dependencies connection details.

Make sure to set the SECRET_KEY to a random string.

You can already fill DJANGO_SUPERUSER_EMAIL, DJANGO_SUPERUSER_USERNAME and DJANGO_SUPERUSER_PASSWORD to create a superuser.

Setup everything¤

You can start up the Postgres and Redis dependencies, apply migrations, load fixtures, create a superuser and collect static files with one shortcut:

pdm run dev-env-setup
What does it do?

It will perform the following steps:

  1. Launch dependencies with Docker
docker-compose up -d db redis
  1. Apply the database migrations
pdm run migrate

This PDM command uses the migrate command of Django to apply migrations on all enabled applications. If you enable a new app (switch PagerDuty on for the first time for instance), you'll need to apply migrations again.

  1. Load fixtures
pdm run loaddata

This PDM command uses the loaddata command of Django to gather necessary objects (Severities, Components, Groups...)

  1. Create a superuser
pdm run createsuperuser

This PDM command will use the env variables set earlier (DJANGO_SUPERUSER_EMAIL, DJANGO_SUPERUSER_USERNAME and DJANGO_SUPERUSER_PASSWORD) to create an admin user. Tou can use this user to login at http://127.0.0.1:8080/admin/

  1. Collect static files
pdm run collectstatic

Run the server¤

You should now be able to run the server locally with:

pdm runserver

This PDM command uses the runserver command of Django.

You can login at http://127.0.0.1:8000/admin/ with the superuser you created.

Warning

If you run the server at this stage, you can expect some warnings/errors.