Deploying a MediaCMS App
Introduction
MediaCMS is an open-source video and media platform built with Django, FastAPI, Celery workers, and a React front end. Deploying MediaCMS with a Dockerfile on Klutch.sh delivers reproducible builds, managed secrets, and persistent storage for uploads and transcoded assets—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production tips.
Prerequisites
- A Klutch.sh account (sign up)
- A GitHub repository containing your MediaCMS code and Dockerfile (GitHub is the only supported git source)
- PostgreSQL database (deploy as a Klutch.sh TCP app on port
8000and connect on5432) - Redis for Celery/queues (optional but recommended; deploy as a TCP app and connect on
6379) - Domain ready for your MediaCMS instance
For onboarding, see the Quick Start.
Architecture and ports
- MediaCMS web/API typically listens on internal port
8000; choose HTTP traffic. - Celery workers run alongside for background jobs; Redis serves as broker/result backend.
- Persistent storage is required for uploads, transcodes, and static assets.
Repository layout
mediacms/├── Dockerfile # Must be at repo root for auto-detection├── requirements.txt # or poetry/pyproject├── manage.py├── mediacms/ # Django project├── frontend/ # React build (optional)├── media/ # Uploads/transcodes (persist)├── static/ # Collected static files (persist)└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Validate locally before pushing to GitHub:
python -m venv .venvsource .venv/bin/activatepip install -r requirements.txtpython manage.py migratepython manage.py collectstatic --noinputgunicorn mediacms.wsgi:application --bind 0.0.0.0:8000Celery (optional local):
celery -A mediacms worker -l infoDockerfile for MediaCMS (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=8000
WORKDIR /app
COPY requirements.txt .RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential ffmpeg libpq-dev && \ pip install --no-cache-dir -r requirements.txt && \ apt-get clean && rm -rf /var/lib/apt/lists/*
COPY . .
# Collect static in image build; adjust if you prefer runtime collectionRUN python manage.py collectstatic --noinput
EXPOSE 8000CMD ["bash", "-lc", "python manage.py migrate && gunicorn mediacms.wsgi:application --bind 0.0.0.0:${PORT:-8000}"]Notes:
- Add a separate process or second app for Celery workers if you need background processing; reuse the same image with
celery -A mediacms worker -l info. - Keep
media/andstatic/writable and mount them as volumes.
Environment variables (Klutch.sh)
Set these in Klutch.sh before deploying:
PORT=8000DJANGO_SECRET_KEY=<secure-random>DJANGO_ALLOWED_HOSTS=example-app.klutch.shDATABASE_URL=postgres://<user>:<password>@<host>:5432/<db>REDIS_URL=redis://:<password>@<host>:6379/0(if using Celery/Redis)MEDIA_URL=/media/andSTATIC_URL=/static/EMAIL_HOST,EMAIL_PORT,EMAIL_HOST_USER,EMAIL_HOST_PASSWORD,EMAIL_USE_TLS(optional)CELERY_BROKER_URLandCELERY_RESULT_BACKEND(if Celery is enabled)TZ=UTC
If you deploy without the Dockerfile and need Nixpacks overrides (Python/Django):
NIXPACKS_PYTHON_VERSION=3.11NIXPACKS_BUILD_CMD=pip install -r requirements.txt && python manage.py collectstatic --noinputNIXPACKS_START_CMD=bash -lc 'python manage.py migrate && gunicorn mediacms.wsgi:application --bind 0.0.0.0:8000'
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/app/media— user uploads, transcodes, thumbnails./app/static— collected static assets (if you prefer to persist them)./app/logs— optional for application logs.
Ensure these directories are writable.
Deploy MediaCMS on Klutch.sh (Dockerfile workflow)
- Push your repository—with the Dockerfile at the root—to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Select HTTP traffic and set the internal port to
8000. - Add the environment variables above, including Postgres/Redis credentials, Django secrets, and email settings.
- Attach persistent volumes for
/app/mediaand, optionally,/app/staticand/app/logswith sizes that fit your storage and retention needs. - Deploy. Your MediaCMS instance will be reachable at
https://example-app.klutch.sh; attach a custom domain if desired.
Sample API usage
List public videos (example endpoint; adjust to your API):
curl -X GET "https://example-app.klutch.sh/api/videos" \ -H "Accept: application/json"Health checks and production tips
- Add an HTTP probe to
/healthor/after configuring a simple view for readiness. - Enforce HTTPS at the edge; forward internally to port
8000. - Pin dependency versions and test upgrades in staging before production.
- Monitor database connections and queue health; scale a worker app if Celery jobs back up.
- Store secrets only in Klutch.sh and rotate them regularly.
- Schedule backups for
/app/mediaand database snapshots; sync backups off-site if needed.
MediaCMS on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 8000 configured, and Postgres/Redis connected, you can deliver a robust media platform without extra YAML or workflow overhead.