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>
114 lines
4.9 KiB
YAML
114 lines
4.9 KiB
YAML
# Counsel Scorecard — application stack (backend + Postgres + migrate).
|
|
#
|
|
# No reverse proxy: the backend serves the API, the console and its own security headers, and is
|
|
# published on host port 8081. For TLS put your own terminator in front (and list its address in
|
|
# FORWARDED_ALLOW_IPS below), or run Counsel as a module of the platform, where Atrium is the front door.
|
|
#
|
|
# ── Host ports ────────────────────────────────────────────────────────────────
|
|
# The family numbers its development ports app / db / static, twenty apart per app:
|
|
# Galena 8012 / 8014 / 8021, Sygna 8032 / 8034 / 8041, Compass 8052 / 8054 / 8061,
|
|
# Counsel 8072 / 8074 / 8081. The stacks therefore run side by side; taking :80 would collide
|
|
# with a sibling stack on the first `up`. Counsel's console + API are published once, on 8081 (8080 stays
|
|
# HyperDX's UI).
|
|
# On the platform the modules publish nothing and Atrium's front door keeps :80.
|
|
#
|
|
# cp .env.example .env # then edit the change_me_* values
|
|
# DREDD_CORE_TOKEN=<read-only Gitea token> docker compose up -d --build
|
|
#
|
|
# The token (read access to the private dredd-core repository) is a BuildKit build secret: keep it in
|
|
# the shell, never in .env (see `secrets:` at the end of this file).
|
|
|
|
networks:
|
|
# The published port needs a non-internal network; Postgres is not on it.
|
|
edge:
|
|
internal:
|
|
|
|
volumes:
|
|
pgdata:
|
|
|
|
services:
|
|
postgres:
|
|
# Pin by digest in production (review L14): `postgres:16-alpine@sha256:<digest>`,
|
|
# resolved via `docker buildx imagetools inspect postgres:16-alpine`.
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
expose: ["5432"] # never `ports` — DB is private to the docker network
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: ${DB_SUPERUSER_PASSWORD}
|
|
DB_APP_PASSWORD: ${DB_APP_PASSWORD}
|
|
DB_MIGRATOR_PASSWORD: ${DB_MIGRATOR_PASSWORD}
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
- ./db/init:/docker-entrypoint-initdb.d:ro
|
|
networks: [internal]
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres -d ${POSTGRES_DB}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
logging: &logging
|
|
driver: json-file
|
|
options: { max-size: "10m", max-file: "5" }
|
|
|
|
# One-shot: applies migrations as `migrator` (DDL), then idempotent seed. Exits 0.
|
|
migrate:
|
|
build:
|
|
context: ./backend
|
|
additional_contexts:
|
|
frontend: ./frontend
|
|
secrets: [dredd_core_token]
|
|
restart: "no"
|
|
env_file: .env
|
|
command: ["sh", "-c", "alembic upgrade head && python -m app.seed"]
|
|
networks: [internal]
|
|
depends_on:
|
|
postgres: { condition: service_healthy }
|
|
logging: *logging
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
# The console (../frontend) is copied into the image from this named context
|
|
# (backend/Dockerfile: COPY --from=frontend).
|
|
additional_contexts:
|
|
frontend: ./frontend
|
|
secrets: [dredd_core_token]
|
|
restart: unless-stopped
|
|
ports: ["8081:8000"]
|
|
env_file: .env
|
|
environment:
|
|
# Nothing sits in front of the backend here, so no hop may set X-Forwarded-For: empty = the
|
|
# image's default (loopback only), and the audit INET columns record the real peer address.
|
|
# Behind your own TLS terminator, set its address or subnet instead (never `*`).
|
|
FORWARDED_ALLOW_IPS: ""
|
|
# Least-privilege (review M1): the runtime backend connects ONLY as the DML `app` role
|
|
# (via DATABASE_URL). Blank the DDL-capable migrator URL + privileged passwords that
|
|
# `env_file: .env` would otherwise inject, so a compromised backend can't connect as
|
|
# `migrator` and run DDL. Migrations run in the one-shot `migrate` service, which keeps
|
|
# the full `.env`. (`environment:` takes precedence over `env_file`.)
|
|
MIGRATION_DATABASE_URL: ""
|
|
DB_MIGRATOR_PASSWORD: ""
|
|
DB_SUPERUSER_PASSWORD: ""
|
|
# No `command:` — backend/Dockerfile's CMD is the one place uvicorn's flags live.
|
|
networks: [edge, internal]
|
|
depends_on:
|
|
postgres: { condition: service_healthy }
|
|
migrate: { condition: service_completed_successfully }
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/api/v1/health').status==200 else 1)"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 20s
|
|
logging: *logging
|
|
|
|
secrets:
|
|
# Used only by the build stage's one `pip install` (backend/Dockerfile); no running container gets it.
|
|
# Compose resolves the variable from the shell OR the project .env (shell wins). Keep it in the shell,
|
|
# because migrate and backend load .env at runtime and would receive the token:
|
|
# DREDD_CORE_TOKEN=<read-only Gitea token> docker compose up -d --build
|
|
dredd_core_token:
|
|
environment: DREDD_CORE_TOKEN
|