From de85cdf5a2d162f736a60af6c10dc483363fe149 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Sat, 4 Apr 2026 23:24:22 +0200 Subject: [PATCH] fix: let SPRING_DATASOURCE_URL fully control datasource connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explicit spring.datasource.url in YAML takes precedence over the env var, causing deployed containers to connect to localhost instead of the postgres service. Now the YAML uses ${SPRING_DATASOURCE_URL:...} so the env var wins when set. Flyway inherits from the datasource (no separate URL). Removed CAMELEER_DB_SCHEMA — schema is part of the datasource URL. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/main/resources/application.yml | 11 +++-------- deploy/overlays/feature/kustomization.yaml | 4 ++-- deploy/overlays/main/kustomization.yaml | 4 ++-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cameleer3-server-app/src/main/resources/application.yml b/cameleer3-server-app/src/main/resources/application.yml index 9d97e0d1..d7b979b3 100644 --- a/cameleer3-server-app/src/main/resources/application.yml +++ b/cameleer3-server-app/src/main/resources/application.yml @@ -3,18 +3,13 @@ server: spring: datasource: - url: jdbc:postgresql://localhost:5432/cameleer3?currentSchema=${CAMELEER_DB_SCHEMA:tenant_${cameleer.tenant.id}} - username: cameleer - password: ${CAMELEER_DB_PASSWORD:cameleer_dev} + url: ${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/cameleer3?currentSchema=tenant_${cameleer.tenant.id}} + username: ${SPRING_DATASOURCE_USERNAME:cameleer} + password: ${SPRING_DATASOURCE_PASSWORD:cameleer_dev} driver-class-name: org.postgresql.Driver flyway: enabled: true locations: classpath:db/migration - url: jdbc:postgresql://localhost:5432/cameleer3?currentSchema=${CAMELEER_DB_SCHEMA:tenant_${cameleer.tenant.id}},public - user: ${spring.datasource.username} - password: ${spring.datasource.password} - schemas: ${CAMELEER_DB_SCHEMA:tenant_${cameleer.tenant.id}} - default-schema: ${CAMELEER_DB_SCHEMA:tenant_${cameleer.tenant.id}} create-schemas: true mvc: async: diff --git a/deploy/overlays/feature/kustomization.yaml b/deploy/overlays/feature/kustomization.yaml index f3eec3b2..f7a19aec 100644 --- a/deploy/overlays/feature/kustomization.yaml +++ b/deploy/overlays/feature/kustomization.yaml @@ -23,8 +23,8 @@ patches: containers: - name: server env: - - name: CAMELEER_DB_SCHEMA - value: "BRANCH_SCHEMA" + - name: SPRING_DATASOURCE_URL + value: "jdbc:postgresql://postgres.cameleer.svc.cluster.local:5432/cameleer3?currentSchema=BRANCH_SCHEMA" - name: CAMELEER_UI_ORIGIN value: "http://BRANCH_SLUG.cameleer.siegeln.net" # UI ConfigMap: branch-specific API URL diff --git a/deploy/overlays/main/kustomization.yaml b/deploy/overlays/main/kustomization.yaml index e5471b7e..a1297a4c 100644 --- a/deploy/overlays/main/kustomization.yaml +++ b/deploy/overlays/main/kustomization.yaml @@ -40,8 +40,8 @@ patches: env: - name: CAMELEER_UI_ORIGIN value: "http://192.168.50.86:30090" - - name: CAMELEER_DB_SCHEMA - value: "public" + - name: SPRING_DATASOURCE_URL + value: "jdbc:postgresql://postgres:5432/cameleer3?currentSchema=public" # UI ConfigMap: production API URL - target: kind: ConfigMap