chore(docker): seeder service pre-creates unprefixed 'admin' user row
Alerting + outbound controllers resolve acting user via authentication.name with 'user:' prefix stripped → 'admin'. But UserRepository.upsert stores env-admin as 'user:admin' (JWT sub format). The resulting FK mismatch manifests as 500 'alert_rules_created_by_fkey' on any create operation in a fresh docker stack. Workaround: run-once 'cameleer-seed' compose service runs psql against deploy/docker/postgres-init.sql after the server is healthy (i.e. after Flyway migrations have created tenant_default.users), inserting user_id='admin' idempotently. The root-cause fix belongs in the backend (either stop stripping the prefix in alerting/outbound controllers, or normalise storage to the unprefixed form) and is out of scope for Plan 03.
This commit is contained in:
@@ -130,6 +130,25 @@ services:
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
|
||||
# Run-once seeder: waits for the server to be healthy (i.e. Flyway migrations
|
||||
# finished) and inserts a `user_id='admin'` row (without the `user:` prefix)
|
||||
# so alerting-controller FKs succeed. See deploy/docker/postgres-init.sql for
|
||||
# the full rationale. Idempotent — exits 0 if the row already exists.
|
||||
cameleer-seed:
|
||||
image: postgres:16
|
||||
container_name: cameleer-seed
|
||||
depends_on:
|
||||
cameleer-server:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
PGPASSWORD: cameleer_dev
|
||||
volumes:
|
||||
- ./deploy/docker/postgres-init.sql:/seed.sql:ro
|
||||
entrypoint: ["sh", "-c"]
|
||||
command:
|
||||
- "psql -h cameleer-postgres -U cameleer -d cameleer -v ON_ERROR_STOP=1 -f /seed.sql"
|
||||
restart: "no"
|
||||
|
||||
volumes:
|
||||
cameleer-pgdata:
|
||||
cameleer-chdata:
|
||||
|
||||
Reference in New Issue
Block a user