diff --git a/docs/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from docs/CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/docs/Contributing/0000-prerequisites.md b/docs/Contributing/0000-prerequisites.md index 40b535f1..4d7572fd 100644 --- a/docs/Contributing/0000-prerequisites.md +++ b/docs/Contributing/0000-prerequisites.md @@ -11,3 +11,5 @@ - [pre-commit](https://pre-commit.com/#install) _(optional, recommended)_ - [asdf](https://asdf-vm.com/#/core-manage-asdf-vm) or [rtx](https://github.com/jdx/rtx) _(optional, recommended)_ - You can install and manage versions of Python, Node, PDM, etc. with these tools. + + diff --git a/docs/Contributing/0001-setup-environment.md b/docs/Contributing/0001-setup-environment.md index e18ed2ac..3ce24032 100644 --- a/docs/Contributing/0001-setup-environment.md +++ b/docs/Contributing/0001-setup-environment.md @@ -3,36 +3,105 @@ The following documentation assume your system meet the [prerequisites](0000-prerequisites.md). -## Set your .env (part 1) +## Clone the repository + +```shell +git clone git@github.com:ManoManoTech/firefighter-incident.git +cd firefighter-incident +``` + +## Load ASDF/RTX/Direnv _(optional)_ + +If you use ASDF, RTX or Direnv, you can load the environment with: + +```shell +asdf install +# or +rtx install +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. + +```shell +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: + +```shell +source .venv/bin/activate +``` + +## Install pre-commit hooks _(optional)_ + +```shell +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 the following environment variables are set in the `.env` file: +Make sure to set the `SECRET_KEY` to a random string. -```bash title=".env (sample)" -TOOLS_COMMON_PGDB_HOST=localhost -INFRA_FIREFIGHTER_V2_CACHE_HOST=localhost +You can already fill `DJANGO_SUPERUSER_EMAIL`, `DJANGO_SUPERUSER_USERNAME` and `DJANGO_SUPERUSER_PASSWORD` to create a superuser. + +## Setup everything + +The following steps can be run with: +```shell +pdm run dev-env-setup ``` -## Local development setup +It will performan the following steps: -### Install PDM +### 1. Launch dependencies with Docker -!!! note "TLDR" - - If you have [pipx](https://pypa.github.io/pipx/installation/) installed, you can use it to install PDM: `pipx install pdm` - - If you don't, install pipx then PDM `pip install --user pipx && pipx install pdm` +```shell +docker-compose up -d db redis +``` -> Consider using ASDF or RTX instead. +### 2. Migrate the database -## Launch dependencies +```shell +pdm run migrate +``` -If you only want the Redis and Postgres run with Docker +### 3. Load fixtures ```shell -docker-compose up -d db redis +pdm run loaddata ``` +### 4. Create a superuser + +```shell +pdm run createsuperuser +``` + +### 5. Collect static files + +```shell +pdm run collectstatic +``` + +## You should now be able to run the server + +```shell +pdm runserver +``` + +You can login at http://127.0.0.1:8000/admin/ with the superuser you created. + + > If you run the server at this stage, you can expect some warnings/errors.