Skip to content

Baljan/cafesys

Repository files navigation

Cafesys

Cafesys is the Django application driving the website of Sektionscafé Baljan. It features staff management and the fantastic Blipp system for coffee.

Setting up a development environment using Docker

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:

  1. Setup a Python virtual environment
python3 -m venv .venv
. .venv/bin/activate
pip install ruff pre-commit
pre-commit install
  1. Login to heroku through the terminal by running:
heroku login
  1. Create a backup of the PostgreSQL database by running:
heroku pg:backups:capture --app baljan
  1. Download a dump of the database to the current directory:
heroku pg:backups:download --app baljan -o docker-entrypoint-initdb.d/latest.dump
  1. Copy .env.tmpl to .env
    Before starting the project, fill in the missing values. You can find them in Bitwarden, or on Heroku!

  2. Build the Cafesys image

docker compose build web
  1. 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

Building for production locally

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.

Running migrations on Heroku

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.

About

Website for Sektionscafé Baljan

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 21