fix: let SPRING_DATASOURCE_URL fully control datasource connection
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m5s
CI / docker (push) Successful in 41s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 37s
SonarQube / sonarqube (push) Successful in 3m26s

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) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-04 23:24:22 +02:00
parent 2277a0498f
commit de85cdf5a2
3 changed files with 7 additions and 12 deletions

View File

@@ -3,18 +3,13 @@ server:
spring: spring:
datasource: datasource:
url: jdbc:postgresql://localhost:5432/cameleer3?currentSchema=${CAMELEER_DB_SCHEMA:tenant_${cameleer.tenant.id}} url: ${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/cameleer3?currentSchema=tenant_${cameleer.tenant.id}}
username: cameleer username: ${SPRING_DATASOURCE_USERNAME:cameleer}
password: ${CAMELEER_DB_PASSWORD:cameleer_dev} password: ${SPRING_DATASOURCE_PASSWORD:cameleer_dev}
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
flyway: flyway:
enabled: true enabled: true
locations: classpath:db/migration 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 create-schemas: true
mvc: mvc:
async: async:

View File

@@ -23,8 +23,8 @@ patches:
containers: containers:
- name: server - name: server
env: env:
- name: CAMELEER_DB_SCHEMA - name: SPRING_DATASOURCE_URL
value: "BRANCH_SCHEMA" value: "jdbc:postgresql://postgres.cameleer.svc.cluster.local:5432/cameleer3?currentSchema=BRANCH_SCHEMA"
- name: CAMELEER_UI_ORIGIN - name: CAMELEER_UI_ORIGIN
value: "http://BRANCH_SLUG.cameleer.siegeln.net" value: "http://BRANCH_SLUG.cameleer.siegeln.net"
# UI ConfigMap: branch-specific API URL # UI ConfigMap: branch-specific API URL

View File

@@ -40,8 +40,8 @@ patches:
env: env:
- name: CAMELEER_UI_ORIGIN - name: CAMELEER_UI_ORIGIN
value: "http://192.168.50.86:30090" value: "http://192.168.50.86:30090"
- name: CAMELEER_DB_SCHEMA - name: SPRING_DATASOURCE_URL
value: "public" value: "jdbc:postgresql://postgres:5432/cameleer3?currentSchema=public"
# UI ConfigMap: production API URL # UI ConfigMap: production API URL
- target: - target:
kind: ConfigMap kind: ConfigMap