No description
  • Python 44.1%
  • HTML 21.4%
  • JavaScript 18.8%
  • SCSS 6%
  • CSS 4.2%
  • Other 5.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Sven Bröckling 0b404ebf71
All checks were successful
Publish container image / publish (push) Successful in 11s
Merge SL1: the Sternlos world's slug is sternlos, old projekt-2070 URLs redirect with 301, release 0.5.1
2026-12-05 18:59:43 +01:00
.forgejo/workflows VR1: PhaseSix 0.5.0: the version in pyproject.toml is shown in the footer and /healthz, a release tag builds the image :X.Y.Z, CHANGELOG.md and RELEASING.md 2026-12-05 14:43:39 +01:00
contrib Note nginx version for http2 and recommend HSTS in the nginx example 2026-10-16 00:56:55 +02:00
entrypoints The image builds psycopg's C implementation against the system libpq (extra prod), dev keeps psycopg[binary]; redis-py parses with hiredis; the deploy no longer runs the unused offline compress 2026-11-27 21:31:20 +01:00
phasesix SL1: the Sternlos world moves from projekt-2070 to sternlos, old URLs answer 301; PhaseSix 0.5.1 2026-12-05 18:56:50 +01:00
.dockerignore Moved the uv project into the phasesix folder. 2026-03-22 19:48:50 +01:00
.editorconfig Campaign Headers 2024-07-30 12:41:47 +02:00
.env.docker django-cachalot really caches: the database engine is a literal (cachalot ignored the old postgresql_psycopg2 alias) and its silenced warning is gone; no persistent connections or server-side cursors behind pgbouncer; the cache gets its own Redis (CACHE_URL), socket timeouts, a 7-day cachalot timeout and no caching of busy tables 2026-11-27 21:32:21 +01:00
.gitignore Require PostgreSQL: drop the SQLite fallback 2026-10-16 16:27:06 +02:00
.pre-commit-config.yaml Upgrade all dependencies to their latest releases, raise the pyproject lower bounds to them, uv 0.13.10 in the image, pre-commit hooks updated; Plot.from_db takes fetch_mode and the room name HMAC names its algorithm (Django 2028 deprecations) 2026-11-27 21:05:36 +01:00
.stylelintrc Character Sheet pdf 2023-03-02 23:10:30 +01:00
CHANGELOG.md SL1: the Sternlos world moves from projekt-2070 to sternlos, old URLs answer 301; PhaseSix 0.5.1 2026-12-05 18:56:50 +01:00
docker-compose.yml django-cachalot really caches: the database engine is a literal (cachalot ignored the old postgresql_psycopg2 alias) and its silenced warning is gone; no persistent connections or server-side cursors behind pgbouncer; the cache gets its own Redis (CACHE_URL), socket timeouts, a 7-day cachalot timeout and no caching of busy tables 2026-11-27 21:32:21 +01:00
Dockerfile The image builds psycopg's C implementation against the system libpq (extra prod), dev keeps psycopg[binary]; redis-py parses with hiredis; the deploy no longer runs the unused offline compress 2026-11-27 21:31:20 +01:00
LICENSE.txt Added GPL License 2023-01-12 20:59:35 +01:00
modals-plan.md Added character and campaign cloning feature 2025-12-10 23:12:25 +01:00
README.md django-cachalot really caches: the database engine is a literal (cachalot ignored the old postgresql_psycopg2 alias) and its silenced warning is gone; no persistent connections or server-side cursors behind pgbouncer; the cache gets its own Redis (CACHE_URL), socket timeouts, a 7-day cachalot timeout and no caching of busy tables 2026-11-27 21:32:21 +01:00
RELEASING.md VR1: PhaseSix 0.5.0: the version in pyproject.toml is shown in the footer and /healthz, a release tag builds the image :X.Y.Z, CHANGELOG.md and RELEASING.md 2026-12-05 14:43:39 +01:00

Phase Six Pen'n'Paper Roleplay Platform

This repository contains the source code which runs the RPG Sites Phase Six and Realms of Tirakan. This is a Django project.

The code is licensed under the GNU GPLv3 as stated in the LICENSE.txt file. However, the text content of both phasesix.org and tirakans-reiche.de (game elements, rules etc.) is licensed under the CC-BY-NC-SA 4.0.

This source code comes with a minimal example set of demo data, which can be inserted into a database to get started.

Getting Started - Docker Compose

To run the project in a docker compose environment, all you need is an installed Docker engine or Docker Desktop, and the docker-compose package.

$ docker-compose up
$ docker-compose exec web .venv/bin/python manage.py migrate
$ docker-compose exec web .venv/bin/python manage.py loaddata demo_data.json
$ docker-compose exec web .venv/bin/python manage.py createsuperuser

You can access the admin interface at http://localhost:8000/admin after that.

Getting Started - Native setup

Alternatively, you can install the needed setup locally on your machine without docker.

You need a Linux (WSL2 works too), macOS (untested) or Windows (untested) machine to run this project. There are some prerequisites used by this django project.

Redis

Phase Six relies on a local redis server. The installation depends on your system. For linux, use your package manager (i.e. apt install redis-server). On macOS, use Homebrew to brew install redis.

The cache (with django-cachalot's ORM query cache) uses CACHE_URL, by default the same Redis as REDIS_HOST/REDIS_PORT. In production it should be a Redis of its own with maxmemory and maxmemory-policy allkeys-lru: cachalot's keys only ever grow, and that policy must not evict the Channels layer or the Celery queues.

PostgreSQL

Phase Six runs on PostgreSQL only, in development and in tests as in production. Install it with your package manager (i.e. apt install postgresql, or brew install postgresql on macOS), then create a role and a database owned by it. The role needs CREATEDB so the test runner can create its test_<name> database:

$ sudo -u postgres createuser --createdb --pwprompt phasesix
$ sudo -u postgres createdb --owner phasesix phasesix

Python and uv

The supported python version is 3.14. A system-wide installed python interpreter is fine, but you want to create a virtualenv. PhaseSix uses uv for requirements. This can be done with:

$ cd phasesix
$ uv sync
$ . .venv/bin/activate

Environment, Database, Superuser

This project uses a .env file to set basic settings (like mail server and database). There is an example .env.example, which can be copied to the name .env in the project folder. Adjust the settings for your needs, in particular DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, DATABASE_HOST and DATABASE_PORT for the database created above. All of them are required.

To create the database tables, run the django migrations:

(venv) $ python manage.py migrate

This will not create a superuser for the site, so you need to use the django management command to do this:

(venv) $ python manage.py createsuperuser

Demo data

After this, a simple setup without any data should be ready to run. Although phase six needs some prerequisites present in the database. A simple set of demo data containing some extensions, weapons, armour and skills can be inserted from a json file.

(venv) $ python manage.py loaddata demo_data.json

Running the local server

To run the local development server, just run the following management command:

(venv) $ python manage.py runserver

A single threaded server will be available at http://localhost:8000. Note that this server is not suitable for production deployment. There are many ways to deploy a django project.

Background tasks (Celery)

With DEBUG=True the dev server runs Celery tasks inline, so it needs no worker. To try the real thing, set CELERY_TASK_ALWAYS_EAGER=False in .env and start a worker and the beat next to runserver:

(venv) $ celery -A phasesix worker -l info
(venv) $ celery -A phasesix beat -l info --schedule /tmp/celerybeat-schedule
(venv) $ celery -A phasesix inspect ping    # is a worker alive?

Broker and results use Redis database 1 (CELERY_BROKER_URL overrides it). The schedule is CELERY_BEAT_SCHEDULE in phasesix/settings.py: delete_anonymous_characters at 04:00 and rebuild_search_index at 04:15, Berlin time.

Deployment

Production setup of phasesix.org

The public sites (phasesix.org, tirakans-reiche.de, division-v.de) run as a Docker Swarm stack behind Traefik, which terminates TLS and routes by host name:

  • web: the Docker image as built, several replicas. Each runs hypercorn with five workers on port 4444 (Dockerfile CMD) and handles all HTTP requests.
  • ws: the same image, one replica, started as daphne -p 4242 -b 0.0.0.0 phasesix.asgi:application. Traefik sends every request below /ws to it (higher router priority, sticky cookie), so all websockets (campaign dice and virtual tables) run in this one daphne process. daphne pings websocket clients every 20 seconds by default, which keeps idle connections open; the websocket settings in phasesix/hypercorn.toml do not apply there.
  • nginx: serves the collected static files and the uploads from a shared data directory on separate hosts (public.phasesix.org, public.tirakans-reiche.de, public.division-v.de). STATIC_URL and MEDIA_URL point there, so they are on a different origin than the site. nginx echoes Access-Control-Allow-Origin for the three site origins, which the virtual table needs: it loads its JavaScript as ES modules, and browsers block those across origins without CORS headers. It sends ETag/Last-Modified and supports Range requests (audio/video seeking).
  • migrate: runs entrypoints/migrate.sh on deploy (migrations, collectstatic without the virtual table's offline dev harness, stylesheet compression).
  • celery_worker (any number of replicas) and celery_beat (exactly one): the same image, started as celery -A phasesix worker and celery -A phasesix beat. They run background tasks and the nightly jobs (CELERY_BEAT_SCHEDULE).
  • PostgreSQL behind pgbouncer in transaction pooling mode, so Django keeps no persistent connections (CONN_MAX_AGE=0) and uses no server-side cursors (DISABLE_SERVER_SIDE_CURSORS).
  • Redis for the Channels layer and the Celery broker. Because of the Redis Channels layer, broadcasts reach clients on any process.
  • A second Redis for the cache (CACHE_URL), with maxmemory and allkeys-lru. django-cachalot caches ORM queries there for up to 7 days; after a restore or another write outside Django, run manage.py invalidate_cachalot.

Recommended for any static/media host: Cache-Control: no-cache for /static/table/ (the table's modules have no hashed file names, so browsers must revalidate them after a deploy), Vary: Origin when echoing CORS headers (the header depends on the requesting site) and X-Content-Type-Options: nosniff.

Other setups

hypercorn does not serve static files or uploads, and Django serves /media/ only with DEBUG=True. Any setup needs a reverse proxy in front of the container that

  • serves /static/ and /media/ (the static-files and media-files volumes in docker-compose.yml), with Range requests and ideally X-Content-Type-Options: nosniff,
  • sends Cache-Control: no-cache for /static/table/,
  • accepts request bodies of at least 55 MB (table uploads are limited to 50 MB by Django),
  • forwards websocket upgrades on /ws/ with a read timeout above the 20 second ping interval (hypercorn pings with the settings in phasesix/hypercorn.toml: every 20 seconds, messages up to 256 KiB),
  • sets Host/X-Forwarded-Host and X-Forwarded-Proto, which Django uses for absolute URLs, CSRF checks and the wss:// URL of the table.

STATIC_URL must be on the same origin as the site (for example /static/), or the static host must send CORS headers for the site's origin, as production does.

contrib/nginx-phasesix.conf is an example nginx site for a single host serving everything on one origin. Production is set up differently (see above); adjust server names, certificates, paths and the upstream address before using it.