Cafesys is the Django application driving the website of Sektionscafé Baljan. It features staff management and the fantastic Blipp system for coffee.
Note: This guide requires that you have installed Python, Docker and Docker Compose (see https://docs.docker.com/compose/install/).
If you are using Windows as OS, start by downloading WSL.
Install the Heroku client:
# WSL/Linux:
curl https://cli-assets.heroku.com/install.sh | bash
# macOS:
brew tap heroku/brew && brew install heroku
If your machine has make
available, you can run:
make setup
Otherwise, follow the steps below:
- Setup a Python virtual environment
python3 -m venv .venv
. .venv/bin/activate
pip install ruff pre-commit
pre-commit install
- Login to heroku through the terminal by running:
heroku login
- Create a backup of the PostgreSQL database by running:
heroku pg:backups:capture --app baljan
- Download a dump of the database to the current directory:
heroku pg:backups:download --app baljan -o docker-entrypoint-initdb.d/latest.dump
-
Copy
.env.tmpl
to.env
Before starting the project, fill in the missing values. You can find them in Bitwarden, or on Heroku! -
Build the Cafesys image
docker compose build web
- Create a superuser for the admin
docker compose run --rm web ./manage.py createsuperuser
Then you're ready to go!
To start the project, run:
make start
# or
docker compose up --build -d web worker
This part requires Buildpacks to be installed
If you want to test the build process that Heroku uses, you can follow the steps defined here.
TLDR: Running pack build baljan/cafesys:heroku
will create an image named baljan/cafesys:heroku
From here you can also test the image. Buildpacks creates a normal Docker image that you can start, but you may have to tweak some environment variables.
Instead of adding a Heroku Release Phase to run migrations, which they do not recommend, they suggest using transactions to run migrations.
You do this by running:
heroku run -a baljan python manage.py migrate
This should be done everytime a change to the database is introduced, either if its through a third party app or through a new model.