read.markets/docker-compose.test.yml
Giorgio Gilestro 411094d7b8 admin: internal-only superadmin console (users, payments, DB stats)
New independent `admin` service (admin.main:app) on the same image, reusing
app.db/app.models read-only. Never runs migrations or the scheduler; issues
SELECTs only.

- Password-gated (ADMIN_CONSOLE_PASSWORD) with a 12h signed cookie; closed by
  default when the password is empty.
- Bound to 127.0.0.1:8091 (SSH-tunnel access); off the intranet/NPM network.
- Pages: overview stats, user list + search, per-user history/payment detail,
  DB usage (information_schema size + row estimates).
- Compose: base `admin` service (+prod DB-host override, test mount); Dockerfile
  bakes admin/ into runtime + test stages.
- Tests: tests/test_admin_console.py (auth, queries, page wiring) — 12 passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 16:08:20 +02:00

47 lines
1.7 KiB
YAML

# Ad-hoc test runner.
#
# STANDALONE — do not combine with docker-compose.yml. The `name:` field
# below puts the test container in its own Compose project (`cassandra-test`)
# so it CANNOT collide with the live prod stack on this host (containers,
# networks, volumes are all namespaced by project).
#
# Usage:
# # Run the full suite:
# docker compose -f docker-compose.test.yml run --rm test
#
# # Run a specific file or test:
# docker compose -f docker-compose.test.yml run --rm test pytest tests/test_email_digest_job.py -v
# docker compose -f docker-compose.test.yml run --rm test pytest -k unsubscribe
#
# # Open a shell in the test image (e.g. to poke around with pytest --pdb):
# docker compose -f docker-compose.test.yml run --rm test bash
#
# # Rebuild after a pyproject.toml change:
# docker compose -f docker-compose.test.yml build test
#
# Tests use an in-memory aiosqlite DB (see tests/conftest.py), so there is
# no MariaDB / Redis dependency and nothing touches the prod database.
name: cassandra-test
services:
test:
build:
context: .
target: test
# Same volume mounts as the dev override — edits on the host take effect
# on the next `run` without rebuilding the image.
volumes:
- ./app:/app/app
- ./admin:/app/admin
- ./tests:/app/tests
- ./alembic:/app/alembic
- ./alembic.ini:/app/alembic.ini:ro
- ./config:/app/config:ro
- ./pyproject.toml:/app/pyproject.toml:ro
environment:
# Sentinels so app.config can be imported without a real .env / DB.
# tests/conftest.py also sets these defensively.
DATABASE_URL: "sqlite+aiosqlite:///:memory:"
CASSANDRA_MOCK: "1"
PYTHONDONTWRITEBYTECODE: "1"