Files
CounselScorecard/docker-compose.managed-db.yml
adminandClaude Opus 5.5 d52c6753ed
CI / Tests (Postgres 16) (push) Successful in 4m49s
CI / Tests (Postgres 17) (push) Successful in 4m41s
CI / License gate (deny GPL/AGPL/SSPL) (push) Failing after 33s
CI / Managed database (shared, emulated, Postgres 17) (push) Successful in 5m15s
Fetch private dredd-core from the Haski Gitea, not GitHub
The Dockerfiles still rewrote credentials for github.com only, so the build
token never reached Gitea and installs worked only while dredd-core was
public. Rewrite http://77.216.148.202:3000/ instead, give every workflow
that pip-installs the same rewrite (org secret DREDD_CORE_TOKEN, the
read-only haski-reader token), and drop the GitHub PAT leftovers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 22:18:19 +01:00

71 lines
4.2 KiB
YAML

# Counsel Scorecard on a managed PostgreSQL database (the family's shared one, or any Postgres 16/17
# reached over a network): an override for docker-compose.yml.
#
# DREDD_CORE_TOKEN=<read-only Gitea token> \
# docker compose -f docker-compose.yml -f docker-compose.managed-db.yml up -d --build
#
# The database lives elsewhere (one database for Atrium, Galena, Sygna and Counsel Scorecard; Counsel
# lives in schema `counsel`), so the local postgres service is switched off and nothing waits for it;
# migrate (+seed) and backend are otherwise unchanged. Counsel must be provisioned first
# (db/managed/README.md), and .env must carry the database's URLs — the provider's host and port
# (through a pooler, its session mode, never transaction mode), users counsel_migrator / counsel_app
# (as <role>.<tenant> where the pooler wants the tenant in the user name), URL-encoded passwords and
# ?sslmode=verify-full&sslrootcert=/run/certs/db-ca.crt — plus DB_APP_ROLE=counsel_app (see the
# managed-database block in .env.example).
#
# Uses the !reset / !override merge tags (docs.docker.com/reference/compose-file/merge/), so it needs a
# Compose v2 release that supports them; `docker compose -f ... -f ... config` shows the merged result.
# Pass -f with BOTH files on every command (ps, logs, run, down), or Compose falls back to the
# local-postgres stack.
#
# Migrations are not retried on failure: some providers ban a client IP for a while after a few failed
# password logins in a row, and a retry loop around a wrong password would trigger exactly that.
services:
postgres:
# Off: a profile nobody activates keeps the service defined but never starts it.
profiles: ["local-postgres"]
# No data volume and no db/init mount: the schema, roles and pg_trgm come from provisioning.
volumes: !reset []
migrate:
# docker-compose.yml makes migrate wait for the local postgres healthcheck; there is none here.
depends_on: !reset null
environment:
# The one-shot migrate service keeps the whole .env: alembic and the seed both run as
# MIGRATION_DATABASE_URL's counsel_migrator. 0002_runtime_grants grants the role DB_APP_ROLE
# names, so an unset DB_APP_ROLE stops here rather than halfway through the migration.
DB_APP_ROLE: ${DB_APP_ROLE:?set DB_APP_ROLE in .env to the runtime role, counsel_app in the shared managed database}
volumes: &managed_db_ca
# The provider's root CA (downloaded from its dashboard), read-only, at the path the URLs'
# sslrootcert names. One file serves the whole shared database. create_host_path: false makes
# a missing file an error at start-up instead of an empty directory in its place.
- type: bind
source: ${MANAGED_DB_CA_FILE:-./certs/db-ca.crt}
target: /run/certs/db-ca.crt
read_only: true
bind:
create_host_path: false
backend:
# docker-compose.yml also makes the backend wait for the local postgres; keep only migrate.
depends_on: !override
migrate: { condition: service_completed_successfully }
environment:
# Least privilege: the long-running backend connects ONLY as counsel_app (DATABASE_URL).
# docker-compose.yml already blanks the migrator's URL and the privileged passwords that
# `env_file: .env` would inject; restated here so this file alone shows the posture: a
# compromised backend cannot log in as counsel_migrator and rewrite audit_log. Counsel has no
# in-app restore, so its backend never needs the migrator. (Galena and Sygna do; keeping the
# migrator in their backends is a documented opt-in, a one-shot restore container the
# recommended path.)
MIGRATION_DATABASE_URL: ""
DB_MIGRATOR_PASSWORD: ""
DB_SUPERUSER_PASSWORD: ""
DB_APP_PASSWORD: ""
# Passed through explicitly so the running configuration is visible here. The pool bounds the
# connections this backend takes from the shared database's limit (db/managed/README.md).
DB_APP_ROLE: ${DB_APP_ROLE:?set DB_APP_ROLE in .env to the runtime role, counsel_app in the shared managed database}
DB_POOL_SIZE: ${DB_POOL_SIZE:-5}
DB_MAX_OVERFLOW: ${DB_MAX_OVERFLOW:-10}
volumes: *managed_db_ca