- Docker Compose V2
git clone --recurse-submodules [email protected]:CyberCRI/projects-backend.git
cd projects-backendif you want to set your environnement variables (Mostly third-parties secrets):
cp .env.sample .envYou can ask the other devs for the secret values to fill the .env file.
docker compose upThe backend and Celery restart multiple times because they keep crashing while Keycloak is not up. After a short moment, your backend will be up and ready.
You can now access:
The stack need to be running. Get a shell access to the backend container
make bash# inside the container
python manage.py migrate# inside the container
python manage.py collectstatic# inside the container
python manage.py compilemessagesA default superadmin is created in keycloak. To import it in Projects, you need to login at least once in the swagger or in Django admin using these credentials:
- username:
adminor[email protected] - password:
admin
You can also use these credentials (use the admin username, not the email) to connect to the Keycloak admin panel
# inside the container
python manage.py seed_db -o <organization_code> -u <organization_url> -a <accounts>This will generate random data and an admin user for the organization you specified.
For local development, you should use:
- organization_code:
CRI(or the code you specified in your frontend) - organization_url:
http://localhost:8080 - accounts (optional): List of comma-separated accounts to create with format
username:password:role. Example:[email protected]:pass1:admins,[email protected]:pass2:users
Run all the tests:
# inside the container
make testRun just one test file or test directory:
# inside the container
# ex:path_to_file=apps.accounts.tests.views.test_people_group
python manage.py test <path_to_file> --settings=projects.settings.test You can check locally that the CI will validate your pull request by running the following commands in your backend container. Your pull request cannot be merged if it doesn't meet these requirements. You can run these tests locally before asking to merge your PR, or you can let the CI run them for you remotely.
- Respect format rules:
# inside the container
make formatThis will automatically update your files
- Respect lint rules:
# inside the container
make lintThis will return errors that you need to fix manually. If there are some, fix them then repeat step 1.
- Keep translations up to date:
# inside the container
make localesThis will detect changes in translated messages. Even if you didn't add, remove or modify any translated message. This might update some files because of line changes on translations caused by your changes.
If there are new messages, be sure to add the translation after running this command.
- Create migrations if needed:
# inside the container
python manage.py makemigrations- Be sure that all tests pass
# inside the container
make testThis work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

