This project is the backend API server for the lupogreybeard-ui and the dbd randomizer mobile app. It is written in Python, using the Django framework. It is backed by a postgres database.
This section outlines the typical workflow for building, testing, and running the Django application using Fabric commands. Each step corresponds to a Fabric task and ensures a smooth lifecycle management process.
Before running any other tasks, ensure that the virtual environment is activated:
fab activate
Install the required Python dependencies:
fab install
Development uses a local database. Check out the instructions in database docs to learn how to set this up.
Then run migrations:
fab migrate
If you need to rebuild the database, you can use:
fab rebuild-db --env=development
This will drop and recreate the database for the specified environment (default is development
, other option is test
).
To build the Docker images for your application:
fab build
Run the Django development server locally:
fab dev
Run the Dockerized development environment:
fab devcontainer
Run all tests in the project. This will set the DJANGO_ENV
to test
and execute pytest
:
fab test
To rebuild the test database before running tests:
fab rebuild-db --env=test
Deploy and run the production environment with Docker:
fab prod
Run database migrations inside the production Docker container:
fab migrate_prod
This command detects the current environment (dev
, production
, or Dockerized development) and stops the appropriate services:
fab stop
Here’s a suggested order for running the lifecycle tasks:
-
Setup and Initialization:
fab activate
fab install
fab migrate
-
Build:
fab build
-
Development:
- Non-Dockerized:
fab dev
- Dockerized:
fab devcontainer
- Non-Dockerized:
-
Test:
- Run Tests:
fab test
- Rebuild Test Database:
fab rebuild-db --env=test
- Run Tests:
-
Production:
- Deploy:
fab prod
- Apply Migrations:
fab migrate_prod
- Deploy:
-
Stop:
fab stop
This project is autodeployed to a DigitalOcean app when a merge is made to main
. This is accomplished using GitHub actions and tools provided by DigitalOcean.
You can see a list of things I would like to add to this site here: wish list