The backend portion of the Rezzi data-platform.
Go to https://docs.docker.com/desktop/ and install Docker Desktop for your system.
You will need to create a django env file and a postgres env file:
docker/.django.env
DJANGO_SETTINGS_MODULE=config.settings.dev
SECRET_KEY="<32 character random string>"
DB_HOST=postgres
DB_PORT=5432
DB_NAME="rezzi"
DB_USER="postgres"
DB_PASSWORD="<Password set in the postgres.env file>"docker/.postgres.env
POSTGRES_PASSWORD="<Add password here for postgres user>"To set up the local environment dependencies and git hooks, run:
make shell
make initIt's recommended to run all of the make commands in the shell opened with make shell.
After setting up your env files you can build the images with make build and then launch the docker compose network with make server. Once the network is up and running, open a new shell to run the migrate and createsuperuser commands.
To finishing setting up the database you will need to apply the database migration with make migrate.
To log into your admin site you will need to create a superuser with make createsuperuser.
Once you have created this superuser you should be able to login to you admin dashboard at localhost:8842/admin/.
The backend acts as the central security authority for the Binsights ecosystem. This means that the frontend must query the Django backend in order to generate the JWT tokens needed to embed Metabase graphs and dashboards. To enable Metabase token generation, get the Metabase JWT secret and add it to your django env file:
METABASE_JWT_SECRET="<Add the Metabase JWT secret here>"Complete the following steps to enable the Django application to connect to BigQuery:
- Download a
.jsonkey file for a GCP Service Account with the rolesBigQuery Job UserandBigQuery Data Viewer - Place the
.jsonkey file in the./docker/secretsproject directory - Add a
GCP_CREDENTIALS_FILENAMEvariable to your django env file (./docker/.django.env)
GCP_CREDENTIALS_FILENAME="<Name of the GCP Service Account key file>"Use the following commands to add a new python dependency to the project:
make shell
pipenv install "dependency-name" # or `pipenv install --dev "dependency-name"`
pipenv requirements > docker/requirements.txt
pipenv requirements --dev-only > docker/requirements-dev.txtThen rebuild your docker image:
make down
make build
make serverThere is a Makefile command that will generate a diagram of the project's data-model. This command makes use of the django-extensions graph_models command, and requires pygraphviz as a dependency. Since pygraphviz tends to be somewhat problematic to install, it has been moved to an optional category in the pipenv dependencies and excluded from the docker containers. To install it on your local machine run: pipenv sync --categories optional. If this doesn't run cleanly check out the pygraphviz installation instructions to debug any problems. Once the optional dependencies are installed you can generate the data-model diagram with:
make models-diagramThe PNG containing the diagram will appear at the project root as rezzi-portal-models-diagram.png.
TODO: rewrite this as a script, find a good place within this project to store the version number
VERSION_NUMBER=0.0.66 && \
docker buildx build --platform=linux/amd64 -f docker/Dockerfile.prod.api -t binsights_prod:$VERSION_NUMBER . && \
DOCKER_IMAGE_ID=$(docker images -q binsights_prod:$VERSION_NUMBER) && \
docker tag $DOCKER_IMAGE_ID registry.digitalocean.com/binsights/binsights-deployment-image:$VERSION_NUMBER && \
docker push registry.digitalocean.com/binsights/binsights-deployment-image:$VERSION_NUMBER