17thshard/palanaeum
À propos
A website for collecting audio interviews and transcribing the questions & answers
Design et médiasProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 0
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalPalanaeum
Palanaeum is a Django web application and REST API for transcribing, archiving, tagging, and searching spoken events (such as Q&As, panels, and livestreams), complete with audio/image source management, audio snippet extraction, user collections, and staff moderation workflows.
Tech Stack & Dependencies
Runtime & Core Services
- Python 3.12, Django 6.0 (
Django==6.0.10), and Gunicorn (gunicorn==27.0.1) with Django REST Framework (3.18.2). - PostgreSQL (
postgres:17indocker-compose.yml) — Required. Palanaeum relies on PostgreSQL-specific full-text search and query features (SearchVectorField,GinIndex,DISTINCT ON, and rawto_tsquerySQL). SQLite is not supported. - Redis (
redis:8indocker-compose.yml) — Used as:- the Celery message broker and result backend,
- the Django cache backend (
default,search, andconfigcaches, pluscached_dbsessions) whenPALA_CACHE_CONFIG=redis, and - the
sorl-thumbnailkey-value store (THUMBNAIL_KVSTORE).
- Celery (
celery==5.7.0) — Runs background tasks inpalanaeum/tasks.py(audio transcoding to MP3, snippet extraction/muting, ZIP backups, and a periodic 6-hourupload_new_sources_to_cloudbeat task).
System Dependencies
ffmpeg&ffprobe(pluslibavcodec-extrain Docker) — Required at runtime for probing audio duration, transcoding uploaded audio to MP3, cutting audio snippets, and muting audio segments.- PostgreSQL client libraries (
postgresql-clientin Docker;psycopg[binary]inrequirements.txt).
Key Python Packages
Installed via requirements.txt (runtime) and requirements-dev.txt (adds test coverage):
- Configuration & Dev:
django-environ,django-extensions(runserver_plus),Werkzeug,django-debug-toolbar(enabled whenPALA_DEBUG=True) - Database, Cache & Tasks:
psycopg[binary],redis,celery - Content, Media & Search:
nh3(HTML sanitization),Pillow,sorl-thumbnail,lxml(HTML diffs in entry version history),requests(URL title scraping & Backblaze B2 API),pytz - API:
djangorestframework,django-filter,django-cors-headers - Testing & Coverage:
factory_boy,coverage(inrequirements-dev.txt)
Local Development Setup
You can run Palanaeum either entirely inside Docker Compose or in a hybrid setup (Dockerized Postgres & Redis + local Python virtualenv).
Option 1: Full Docker Compose Stack
Start all services (
db,redis,web, andcelery):docker compose up --build(
webrunsmanage.py runserver_plusonhttp://127.0.0.1:9000/, with the repository bind-mounted at/appfor live reload.)On first launch, apply migrations and create a superuser:
docker compose exec web python manage.py migrate docker compose exec web python manage.py createsuperuserAfter pulling new changes (which may include updated requirements or migrations):
docker compose up --build docker compose exec web python manage.py migrate
Note:
docker-compose.ymlsetsPALA_ENV_FILE=/dev/nulland injects container-specific environment variables (PALA_DB_HOST=db,PALA_DB_USER=docker,PALA_DB_PASSWORD=docker,PALA_CACHE_CONFIG=redis) so container config does not conflict with a host.envfile.
Option 2: Hybrid Local Setup (Local Python + Docker Postgres & Redis)
Start PostgreSQL and Redis in Docker:
docker compose up -d --wait db redisCreate a Python 3.12 virtual environment and install dependencies:
python3.12 -m venv .venv .venv/bin/pip install -r requirements-dev.txt(Use
-r requirements.txtif you do not needcoverage.)Create your local
.envfrom.env.exampleand match the Docker PostgreSQL credentials:cp .env.example .envIn
.env, set at least:PALA_DEBUG=True PALA_DB_HOST=127.0.0.1 PALA_DB_PORT=5432 PALA_DB_NAME=palanaeum PALA_DB_USER=docker PALA_DB_PASSWORD=docker PALA_REDIS_HOST=127.0.0.1 PALA_REDIS_PORT=6379 PALA_CACHE_CONFIG=redisRun database migrations, create a superuser, and start the development server:
.venv/bin/python manage.py migrate .venv/bin/python manage.py createsuperuser .venv/bin/python manage.py runserver_plusPalanaeum will be available at
http://127.0.0.1:9000/.(Optional) Start a local Celery worker if you are working on audio uploads, snippet creation/muting, or cloud uploads:
.venv/bin/celery -A palanaeum worker -l infoTo also run periodic tasks (
upload_new_sources_to_cloudevery 6 hours), run Celery Beat in another terminal:.venv/bin/celery -A palanaeum beat -l info
Audio playback note: Django's development server does not support HTTP byte-range requests (
206 Partial Content), so seeking inside audio files in the browser requires serving media through a production web server such as Nginx (configured indeploy/k3s/).
Running the Test Suite
Palanaeum uses Django's built-in test runner configured via TEST_RUNNER = "palanaeum.tests.runner.PalanaeumTestRunner" in palanaeum/settings.py.
Prerequisites & Isolation
- PostgreSQL must be running (
docker compose up -d --wait db) and your configuredPALA_DB_USERmust have permission to create and drop thetest_palanaeumdatabase (thedockerrole indocker-compose.ymlhas this by default). - Live Redis and Celery workers are not required.
PalanaeumTestRunner(palanaeum/tests/runner.py) isolates every test run from local development state by:- redirecting
MEDIA_ROOT,CONFIG_UPLOADS,UPLOAD_DIRECTORY,CHUNKS_DIRECTORY, andBACKUP_DIRto a temporary directory cleaned up after the run, - overriding
CACHES(default,search,config) toDummyCache(and rebinding module-level caches when individual tests opt intoLocMemCache), - switching
sorl-thumbnailtocached_db_kvstoreand Celery tomemory://, - using
MD5PasswordHasherfor fast user/auth setup, and - resetting
GlobalRequestKeeperthread-local requests and active timezones before and after each test.
- redirecting
ffmpeg/ffprobeis optional: most task tests mocksubprocess.run, whiletest_transcode_source_real_ffmpeg_smokeinpalanaeum/tests/test_tasks.pyperforms a real WAV-to-MP3 transcode if both binaries are present onPATHand automatically skips otherwise.
Test & Coverage Commands
Using the local virtual environment:
# Run the full test suite (203 tests)
.venv/bin/python manage.py test
# Verbose output
.venv/bin/python manage.py test --verbosity=2
# Run a single test module, class, or test method
.venv/bin/python manage.py test palanaeum.tests.test_search
.venv/bin/python manage.py test palanaeum.tests.test_models.EventModelTests
# Run with line and branch coverage (configured in .coveragerc)
.venv/bin/coverage run manage.py test
.venv/bin/coverage report
Or inside the Docker web container:
docker compose exec web python manage.py test
Configuration & Environment Variables
All Django settings live in palanaeum/settings.py, powered by django-environ. Every project-specific environment variable uses the PALA_ prefix, loaded from the environment or .env (override path with PALA_ENV_FILE). See .env.example for all supported variables:
| Area | Key Variables | Notes |
|---|---|---|
| Core & Security | PALA_DEBUG, PALA_SECRET_KEY, PALA_ALLOWED_HOSTS, PALA_CSRF_TRUSTED_ORIGINS, PALA_USE_X_FORWARDED_PROTO, PALA_SECURE_COOKIES |
PALA_SECRET_KEY is required whenever PALA_DEBUG=False (including collectstatic builds). |
| Appearance | PALA_STYLE, PALA_TINYMCE_API_KEY |
PALA_STYLE must be blue (default), green, or pink. Compiled CSS lives under palanaeum/static/palanaeum/css/ (SCSS sources in palanaeum/sass/). |
| Database | PALA_DB_HOST, PALA_DB_PORT, PALA_DB_NAME, PALA_DB_USER, PALA_DB_PASSWORD |
PostgreSQL connection parameters. |
| Redis & Cache | PALA_REDIS_HOST, PALA_REDIS_PORT, PALA_REDIS_DB, PALA_CACHE_CONFIG |
PALA_CACHE_CONFIG accepts dummy (default) or redis. |
| Storage Paths | PALA_MEDIA_ROOT, PALA_BACKUP_DIR, PALA_UPLOAD_DIRECTORY, PALA_CHUNKS_DIRECTORY |
Media, backups, and Fine Uploader chunk directories. |
PALA_EMAIL_HOST, PALA_EMAIL_PORT, PALA_EMAIL_USER, PALA_EMAIL_PASSWORD, PALA_EMAIL_BACKEND, PALA_ADMINS |
Defaults to console.EmailBackend when PALA_EMAIL_HOST is empty. |
Runtime Site Configuration & Sites Module
- Site config (
/admin/): Runtime settings (page_title,default_page_length, review notices, upload size limits, audio bitrate, Backblaze B2 cloud credentials, logo/favicons, navbar items, and related sites) are stored in theConfigEntrytable (initialized onmigrate) and edited through Palanaeum's built-in admin interface at/admin/(superuser accounts only). - Sites module: Django's
django.contrib.sitesframework is enabled (PALA_SITE_ID, default1). Update theSiterecord's domain and display name in the database (for example viamanage.py shell) for feeds, sitemaps, and password-reset emails.
Useful Management Commands
# Rebuild PostgreSQL full-text search vectors (EntrySearchVector)
python manage.py rebuild_search_index
# Generate sample events for local development
python manage.py generate_and_insert_test_events -n 5
# Create a ZIP backup (dumpdata + media/) in PALA_BACKUP_DIR
python manage.py backup
# Batch re-transcode audio sources/snippets or upload ready sources to cloud storage
python manage.py transcode_all
python manage.py upload_to_cloud
# Collect static files (provide PALA_SECRET_KEY if PALA_DEBUG=False)
PALA_SECRET_KEY=build-only-key python manage.py collectstatic --noinput
REST API, Feeds & Sitemaps
- REST API (
/api/): Read-only DRF viewsets forevents,upcoming_events,tags,entry,search_entry, andrandom_entry(with browsable login at/api-auth/). Default rate throttles are30/min(anonymous) and10/second(authenticated). - Generating API tokens:
Send the token in the HTTPpython manage.py drf_create_token <username>Authorizationheader:Authorization: Token <your_token_here> - Feeds & Sitemap:
/recent/feed/and/events/<id>-<slug>/feed/(RSS feeds)/sitemap.xml(event sitemap)
Building & Pushing Docker Images (GHCR)
Production images are published to GitHub Container Registry (ghcr.io/17thshard/palanaeum). The root Dockerfile sets the org.opencontainers.image.source label so pushed images automatically link to the 17thshard/palanaeum repository.
Authenticate Docker with GHCR using a GitHub Personal Access Token (classic) (
ghp_...) that has thewrite:packagesscope (also grantsread:packages; fine-grainedgithub_pat_...tokens are not supported by GHCR):echo "$GITHUB_TOKEN" | docker login ghcr.io -u <your-github-username> --password-stdinBuild and push the image (targeting
linux/amd64for the k3s host; passing the short commit SHA asPALA_VERSION_TAGkeeps?v=...static cache-busting query strings consistent across Gunicorn workers):SHA=$(git rev-parse --short HEAD) docker build --platform linux/amd64 \ --build-arg PALA_VERSION_TAG="$SHA" \ -t ghcr.io/17thshard/palanaeum:latest \ -t "ghcr.io/17thshard/palanaeum:$SHA" \ . docker push ghcr.io/17thshard/palanaeum:latest docker push "ghcr.io/17thshard/palanaeum:$SHA"Package visibility (first push only): Open
https://github.com/orgs/17thshard/packages->palanaeum-> Package settings and either set visibility to Public so k3s can pull without credentials, or configure animagePullSecretsdocker-registrysecret in thepalanaeumnamespace if keeping it private.Roll out the new
:latestimage on k3s:kubectl -n palanaeum rollout restart deployment/web deployment/celery-worker deployment/celery-beat
Deployment, Contributing & License
- Production deployment manifests for k3s (Gunicorn + Nginx sidecar, PostgreSQL, Redis, Celery, Traefik Ingress) live under
deploy/k3s/, alongside the rootDockerfileanddocker-compose.yml. - See
CONTRIBUTING.mdfor contribution guidelines and community channels. - Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) — see
LICENSE.
Explorer des projets similaires
Chargement…