refactor(docker): move datastore, graph, search and kafka env into env/docker
Stacked on #21824 (step 3a). Moves the primary datastore, graph, search and Kafka values out of the docker/profiles/ compose anchors into env/docker layer files and new variant folders. The rendered compose config is unchanged in every scenario.
Moved keys
| Key | From anchor | To file |
|---|---|---|
EBEAN_DATASOURCE_{USERNAME,PASSWORD,HOST,URL,DRIVER} (MySQL) | x-primary-datastore-mysql-env | env/docker/{system-update,gms,mae-consumer,mce-consumer}.env |
EBEAN_DATASOURCE_* (Postgres), EBEAN_POSTGRES_USE_AWS_IAM_AUTH, DATAHUB_PGQUEUE_ENABLED, DATAHUB_PGQUEUE_MAINTENANCE_CRON_ENABLED | x-primary-datastore-postgres-env | env/docker/variants/postgres/{system-update,gms,mae-consumer,mce-consumer}.env |
CASSANDRA_*, ENTITY_SERVICE_IMPL, plus the inline ZDU_STAGE_20: 'false' | x-primary-datastore-cassandra-env | env/docker/variants/cassandra/{system-update,gms}.env |
GRAPH_SERVICE_IMPL=elasticsearch | x-graph-datastore-search-env | the four service files |
GRAPH_SERVICE_IMPL=neo4j, NEO4J_* | x-graph-datastore-neo4j-env | env/docker/variants/neo4j/{system-update,gms}.env |
ELASTICSEARCH_{HOST,PORT,PROTOCOL,USE_SSL,IMPLEMENTATION,INDEX_DOC_IDS_SCHEMA_FIELD_HASH_ID_ENABLED} | x-search-datastore-opensearch-env | the four service files |
ELASTICSEARCH_{HOST,PORT,PROTOCOL,USE_SSL} | x-search-datastore-elasticsearch-env (actions) | env/docker/actions.env |
KAFKA_BOOTSTRAP_SERVER, SCHEMA_REGISTRY_TYPE | x-kafka-env, inline in system-update, frontend, actions | service files (frontend and actions already had the same value) |
The stale values the service files carried (ELASTICSEARCH_HOST=elasticsearch, GRAPH_SERVICE_IMPL=neo4j, older MySQL URLs) are replaced in place by the effective values. The unused x-search-datastore-search anchor in docker-compose.prerequisites.yml is deleted.
Variant folders
Order in each list: datastore, graph, debug. Compose does not merge lists, so docker-compose.gms.yml defines 12 anchored env_file lists (x-env-files-<service>-<variants>), one per service and variant set.
postgres: system-update, gms, mae-consumer and mce-consumer services of thequickstart-postgres*anddebug-postgres*profiles.cassandra: system-update and gms ofquickstart-cassandra(withneo4j) anddebug-cassandra.neo4j: system-update and gms ofquickstart-cassandraanddebug-neo4j.
No mysql folder is needed. The datasource user and password read DATAHUB_EBEAN_DATASOURCE_ROOT_*, a name no env file sets, so the Postgres variant's default still applies after the MySQL one.
Kept in environment:
KAFKA_SCHEMAREGISTRY_URLand the actionsSCHEMA_REGISTRY_URL: they interpolateDATAHUB_GMS_BASE_PATH, which stays inenvironment:too, so both read the same shell value.- Per-engine search overrides on the opensearch2, opensearch3 and elasticsearch services: there is no variant folder for search engines.
DATAHUB_MESSAGING_TRANSPORT: its default differs between postgres (pgqueue) and postgres with CDC (kafka). A later env file cannot change an opt-in default an earlier one set.DATAHUB_SQL_SETUP_ENABLED: 'false'on the Cassandra system-update services: the baseenvironment:value would beat a variant file.
Verification
The env snapshot tool (#21820) ran on this branch and on its base (#21824):
bare,shell,smoke,ai,zdu: 71 scenarios, no differences. That includes ad-hoc env files: none of them now wins over a moved key.- Gradle: all 27
quickstart_configskeys, includingquickstart,quickstartDebug,quickstartPostgresandquickstartCassandra, rendered with the env and arguments that:docker:printComposeSettings(from #21820) reports. No differences.quickstartDebugSearchSplitdoes not render on either side, because its override file is not in the repo. ./gradlew :docker:generateQuickstartComposeConfigproduces no diff, and the generated file has noenv_filekey.smoke-test/check_env_parity.py: exit 0.datahub-upgrade.sh -u SystemUpdateagainst a running local stack: the upgrade job ran and succeeded.
Legacy consumers
These read the env files directly and now get the profile values instead of stale ones. The old values pointed at hosts the profile stacks do not run.
docker/datahub-upgrade/datahub-upgrade.sh(env/docker/system-update.env): the script no longer usesdocker run --env-file, which passes${...}literally. It pipes a one-service compose file, withenv_file: ../../env/docker/system-update.env, intodocker compose ... -f - run --rm -T upgrade. Compose resolves${KEY:-default}and${KEY}from the shell, as it does for the stack's own services, so those lines are no longer skipped. The README explains this; its plaindocker runexamples still drop those lines. Changed values:EBEAN_DATASOURCE_USERNAME:datahubārootEBEAN_DATASOURCE_URL: gains&rewriteBatchedStatements=true&enabledTLSProtocols=TLSv1.2ELASTICSEARCH_HOST:elasticsearchāsearchGRAPH_SERVICE_IMPL:neo4jāelasticsearch- New keys:
ELASTICSEARCH_PROTOCOL=http,ELASTICSEARCH_USE_SSL=false,ELASTICSEARCH_IMPLEMENTATION=opensearch,ELASTICSEARCH_INDEX_DOC_IDS_SCHEMA_FIELD_HASH_ID_ENABLED=true,SCHEMA_REGISTRY_TYPE=INTERNAL - The
${...}lines from step 3a, which the script skipped before, are now passed with their resolved values. - Known limitations, older than this change and not fixed here: run on its own, the script still needs
DATAHUB_SYSTEM_CLIENT_SECRET,DATAHUB_TOKEN_SERVICE_SIGNING_KEYandDATAHUB_TOKEN_SERVICE_SALTfrom the shell, because the env file never carried them; and the image tag usesDATAHUB_VERSIONdirectly, so the script'sVERSIONdefault (quickstart) is not applied.
docker/mysql/docker-compose.mysql.yml(env/docker/gms.envthrough compose) gets the same changes: userroot, hostsearch, the Elasticsearch graph, and the new search and schema registry keys.
Deferred
- CDC env: the CDC key sets differ from service to service. A later PR will make them uniform and then move them.
- LocalStack env: it moves with the cloud keys. Its
AWS_REGIONonly beats the bareAWS_REGION:pass-through through merge order.
Checklist
- The PR conforms to DataHub's Contributing Guideline (PR Title Format)
- Links to related issues (if applicable)
- Tests for the changes have been added/updated (if applicable): no new tests; verified with the snapshot tool above
- Docs related to the changes have been added/updated (if applicable):
env/README.md,docker/datahub-upgrade/README.md - For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes: not needed
š¤ Generated with Claude Code
Summary by cubic
Moves datastore, graph, search, and Kafka defaults from Compose anchors into env/docker service files and Postgres, Cassandra, and Neo4j variants, without changing the rendered Compose configuration.
datahub-upgrade.shnow runs the job through a one-servicedocker compose runso${KEY}and${KEY:-default}lines insystem-update.envresolve from the shell environment; it no longer needs a hostperlor drops the placeholders.- Schema-registry URLs and profile-specific overrides (search engine, messaging transport, Cassandra SQL setup) stay in
environment:where moving them would change value resolution; CDC and LocalStack settings remain there for now.