/seedkit
Project name: 09-ssh-deploy
Purpose: production app deployed to a remote host over SSH from GitHub Actions, using self-hosted services.
Settings layout: split.
Database: PostgreSQL.
Postgres location: Postgres-in-Docker (`db` + `redis` services in `docker-compose.yml`, port `127.0.0.1:5432` published).
Lint with Ruff: yes.
Test runner: pytest + pytest-django.
Type check (pyright + django-stubs): no.
Pre-commit hooks: no.
Internationalisation (i18n): no.
Custom user model: no.
Auth add-on: none.
Structured logging: yes (`structlog`, JSON in prod / pretty in dev, request-scoped `request_id`).
Task runner: mise.
Add-ons:
- redis
- tasks: Django Tasks with the Redis Queue backend (`django-tasks-rq`). Also `uv run manage.py startapp jobs`, register `jobs` in `INSTALLED_APPS`, wire `jobs/apps.py` `ready()` to import `tasks`, and add a sample `@task` to `jobs/tasks.py`.
- analytics: Umami (self-hosted, env-driven website ID and host)
- email: none (this project does not send transactional mail and the test verifies the skip path).
- CORS: no.
- REST API: none.
- Frontend: none.
- Auth hardening: N/A (auth = none).
- Health check endpoints: yes.
- `robots.txt`: no.
- `django-extensions`: no.
- Devcontainer: no.
Production setup:
- apply Django security settings
- CSP via `django-csp`: yes
- error reporting: Bugsink (self-hosted, sentry-sdk DSN)
- GDPR: PII scrubbing in error reports, retention defaults, user data export/delete
- CI: GitHub Actions test workflow
- deploy: GitHub Actions deploy via SSH (rsync + remote `docker compose pull && up -d`)
- database backups via `django-dbbackup`: yes (self-managed host — no native backup service)
- production Dockerfile: multi-stage — uv builder → `python:3.12-slim-bookworm` runtime
Run the foundation + boot check locally. Generate `Dockerfile`, `docker-compose.prod.yml`, `.github/workflows/test.yml`, `.github/workflows/deploy.yml`. Do not actually deploy — verify all artifacts are present, `docker build .` succeeds, and the deploy workflow references `secrets.SSH_HOST`, `secrets.SSH_USER`, `secrets.SSH_KEY`.
Production app deployed to a remote host over SSH from GitHub Actions, using self-hosted services.
- Django 6, split settings (
config/settings/{base,local,production,test}.py) - PostgreSQL (Postgres-in-Docker for local dev —
db+redisindocker-compose.yml) - Redis — cache (
/0) +django-tasks-rqqueue (/3) - Background tasks — Django Tasks with the Redis Queue backend (
django-tasks-rq), app:jobs - Structured logging —
structlog+django-structlog(pretty console in dev, JSON in prod, request-scopedrequest_id) - Analytics — Umami (self-hosted, env-driven website ID + host)
- Lint — Ruff
- Tests — pytest + pytest-django
- Task runner — mise
- Health checks —
/healthz(liveness),/readyz(DB readiness) - Security — Django deploy security settings + CSP (
django-csp) - Error reporting — Bugsink (self-hosted, Sentry protocol), PII scrubbed
- GDPR — user data export/delete management commands (
jobs/management/commands/) - Database backups —
django-dbbackupto S3-compatible storage - CI — GitHub Actions (
.github/workflows/test.yml) - Deploy — GitHub Actions via SSH: builds and pushes a GHCR image, then checks out the same commit on the host and runs
deploy/release.sh(.github/workflows/deploy.yml) - Production image — multi-stage:
ghcr.io/astral-sh/uv:python3.12-bookworm-slimbuilder →python:3.12-slim-bookwormruntime
cp .env.example .env # then set a real DJANGO_SECRET_KEY
docker compose up -d # db + redis
mise run install
mise run migrate
mise run superuser
mise run devOpen http://127.0.0.1:8000/admin/ and sign in.
In a second terminal, run the background worker:
mise run workerFallback without mise: uv run manage.py <command>.
| Task | mise | Fallback |
|---|---|---|
| install deps | mise run install |
uv sync |
| run dev server | mise run dev |
uv run manage.py runserver |
| migrate | mise run migrate |
uv run manage.py migrate |
| makemigrations | mise run makemigrations |
uv run manage.py makemigrations |
| shell | mise run shell |
uv run manage.py shell |
| superuser | mise run superuser |
uv run manage.py createsuperuser |
| test | mise run test |
uv run pytest |
| lint | mise run lint |
uv run ruff check . |
| format | mise run fmt |
uv run ruff format . |
| task worker | mise run worker |
uv run manage.py rqworker default |
| collectstatic | mise run collectstatic |
uv run manage.py collectstatic --noinput |
First-time mise setup: mise trust && mise install.
The local docker-compose.yml publishes Postgres on 127.0.0.1:5433 and Redis on 127.0.0.1:6380
(shifted from the defaults 5432/6379 to avoid clashing with any host-native Postgres/Redis already
running on this machine). .env matches these ports.
Deploy target: GitHub Actions via SSH. Every push to main runs the test workflow, builds and pushes
a Docker image to GHCR, then checks out that commit on the host and runs the versioned release script. The workflow completes when the application answers HTTP 200 on /readyz.
Repo secrets required: SSH_HOST, SSH_USER, SSH_KEY, GHCR_TOKEN (a PAT with read:packages,
used by the server to pull the private image).
On the VPS, give the deploy user read access to the project repository and clone it once into /srv/09-ssh-deploy. Use a dedicated checkout and a unique Compose project name for this application. Set COMPOSE_PROJECT_NAME in the server env file. On an existing installation, use the current name from docker compose ls so the same volumes are selected. Copy deploy/.env.prod.example to the gitignored deploy/.env.prod, fill in the server credentials and set GITHUB_REPOSITORY to the GHCR repository path there. Preserve the server-owned env file when moving an existing deployment into the checkout.
Use a known-good full commit SHA whose image is still in GHCR and whose schema is compatible with the current database:
cd /srv/09-ssh-deploy
git fetch origin main
git checkout --no-overwrite-ignore --detach "${KNOWN_GOOD_SHA:?set a known-good commit SHA}" &&
sh deploy/release.sh rollbackFrom the examples repository root, run uv run --script train/verify-ssh-release.py with Docker running. The drill uses its own Git checkout, images, Compose project, database and volumes.
| Check on 2026-11-26 | Observed result |
|---|---|
| PostgreSQL 17 backup and restore with django-dbbackup 5.3.0 | Restored primary key 42 from a local S3-compatible test bucket into a separate empty database. |
| Deploy A, deploy B, roll back to A | Web and worker image markers, service environment and the active Caddy route matched each revision. The server env file and seeded record survived. |
| Database unavailable after migration | The release exited nonzero. Liveness returned 200 and readiness returned 503. |
Built with Seedkit.