Deployment candidate (container-first)
0267c458207082337d9baf1130deeb65f43c9d4a. Version 1.0.1. License MIT. Status: implemented-and-automatically-verified candidate; not published, deployed or production-qualified. This is the component's committed documentation, not proof of a distribution release or production qualification.
This repository ships a deployment candidate, not a published release. No image, binary or compose stack is published from an agent session. Build it, exercise it in a disposable environment, and review the licensing notes before distributing anything.
Image
Dockerfile is multi-stage:
- build stage
rust:1.100-bookworm(the repository pins Rust 1.100.1 throughrust-toolchain.toml), building--release --locked --bin melodee-api; - runtime stage
debian:bookworm-slimwithca-certificates,curl,ffmpegandlibchromaprint-tools, a systemmelodeeuser (non-root),/var/lib/melodeeas the volume root,MELODEE_HTTP_BIND=0.0.0.0:8080, a/readyzhealth check and an entrypoint ofmelodee-api serve.
The image carries OCI labels derived from the release: version, revision,
source, title, description and licenses. Pass VERSION and VCS_REF
explicitly; the build stage refuses a VERSION build argument that differs from
the checked-in VERSION file.
docker build \
--build-arg VERSION="$(cat VERSION)" \
--build-arg VCS_REF="$(git rev-parse HEAD)" \
-t melodee-api:"$(cat VERSION)"-candidate .
docker run --rm --entrypoint /usr/local/bin/melodee-api \
melodee-api:"$(cat VERSION)"-candidate --version
docker image inspect --format '{{json .Config.Labels}}' melodee-api:"$(cat VERSION)"-candidate
--version must print melodee-api 1.0.1, and the labels must report the same
version and revision. The 1.0.0 baseline and 1.0.1 remediation candidate are not
published; see
release process.
Pin the base images by digest in the release pipeline and record the digests.
docs/licenses.md records the unresolved media-tool licensing decision; do not
publish an image before that review.
Compose
docker-compose.yml provides PostgreSQL 17 and the API with named volumes. It is a
single-host starting point, not a high-availability design.
export MELODEE_DB_PASSWORD='…'
export MELODEE_PUBLIC_BASE_URL='https://music.example.test'
docker compose config >/dev/null # validate interpolation
docker compose up -d postgres
docker compose run --rm api migrate --check --require-current
docker compose run --rm api migrate
docker compose run --rm api bootstrap --name "Ada Administrator"
docker compose up -d api
The bootstrap command prints the one-time challenge; complete it at
POST /api/v1/auth/bootstrap or in the Auth UI, then enroll a passkey or verify a
contact. See bootstrap.
docker compose run needs the same environment as the service. Provide secrets
through the platform secret source (or an untracked .env file); never commit
MELODEE_DB_PASSWORD, SMTP, Google, Telegram or WebAuthn secrets.
Health, readiness and shutdown
| Endpoint | Meaning |
|---|---|
GET /healthz | process liveness; never touches dependencies |
GET /readyz | PostgreSQL answers and a writable Storage Volume is mounted |
GET /api/v1/admin/metrics | bounded Prometheus gauges (requires operational authority) |
SIGTERM/SIGINT stop the listener gracefully; the worker loop is aborted after
the HTTP server drains, and in-flight job leases expire and are retried. A
container stop timeout of at least 30 seconds is recommended.
Metrics and logging
MELODEE_LOG_FORMAT=json produces structured logs; text is the default for
development. GET /api/v1/admin/metrics exposes melodee_up,
melodee_build_info, melodee_db_ready and melodee_storage_writable only. Use
an automation credential with operations.read for scraping, or an interactive
session holding admin_jobs. There are no per-request counters yet; reverse-proxy
access logs and report Server-Timing cover request latency.
Storage volumes
Register each physical volume (local or NFS) and initialise it with the volume
marker. A missing mount makes its assets 503/unavailable; the process never
falls back to a local path or deletes catalog rows. Mount volumes read-write into
the container at stable paths and update storage_volume.mount_path to those paths.
Keep the volume marker file and owner epoch with the media.
Reverse proxy and UI boundaries
Serve the API and the separately built Auth UI and Admin UI from the same
origin; browser session cookies rely on it (ADR 0009). Examples:
nginx and
Caddy. Preserve Origin and Sec-Fetch-*; enable HTTPS/HSTS;
rate-limit /api/v1/public/shares/ (the API has no per-IP limiter); raise body
limits for artwork (10 MiB) but not globally.
The API remains headless: do not bake either UI into this image, and do not expose
/api/v1/admin/* to the public internet without the proxy's authentication layer
in addition to the API's own capability checks.
Retention
The durable Cleanup job removes expired sessions/links/nonces/device codes,
report rollups/snapshots older than the configured windows, share access records
older than 30 days, expired/revoked shares older than 90 days and user-state
import plans older than 365 days. Historical play summaries, listener events,
favorites, ratings, dislikes and playlists are not automatically deleted.
Operational notification rows are pruned only when a retention policy is added;
see the notifications gap in the master completion audit.
Backup and restore
scripts/backup_restore_test.py performs a disposable rehearsal: it creates a
synthetic catalog plus favorites, ratings, dislikes, playlists (with a repeated
occurrence), listening history, a historical summary, a verified contact, a
passkey with its protected object, artwork and a public share, then dumps/restores
PostgreSQL, copies two volumes and compares all rows and bytes.
bash scripts/dev-db.sh exec bash -c 'python3 scripts/backup_restore_test.py'
Latest disposable result: 29 compared rows, both media digests and the artwork
digest matched, and the restored API served readiness, search and 206 ranged
playback (see backup and restore). Off-host backups, PITR,
encryption keys and a real-size restore remain owner qualification.
Upgrade and rollback
- Back up PostgreSQL and every Storage Volume.
- Run
melodee-api migrate --check --require-currentagainst the new binary: it fails on an edited applied migration, a downgrade or (with the flag) pending migrations. - Apply migrations with
melodee-api migrate. - Start the new binary, check
/readyzand the metrics, then verify bootstrap sign-in and ranged playback.
Migrations are forward-only. A binary rollback does not roll back a database schema change; keep the previous binary only when it remains compatible with the applied schema, otherwise restore the database backup into the previous schema. Never claim that an older binary is safe against a newer schema.
Not published
No image, compose stack, package or release was published, and no production or Proxmox system was modified during implementation. Multi-arch images, hosted CI image builds and a production-like restore are external qualification items.