refactor: standardize environment variable naming and add PING_SERVICE_URL configuration

Aligned environment variable naming across backend and infrastructure files for improved consistency (e.g., `SPRING_CLOUD_CONSUL` and `SPRING_SECURITY_OAUTH2_RESOURCESERVER`). Introduced `PING_SERVICE_URL` to support dynamic Ping-Service routing. Updated Docker Compose health checks, profiles, and memory settings for scalability and stability.
This commit is contained in:
2026-02-13 15:00:12 +01:00
parent cafb3935cb
commit 6c50f22773
9 changed files with 124 additions and 84 deletions
@@ -1,5 +1,6 @@
package at.mocode.infrastructure.gateway.config
import org.springframework.beans.factory.annotation.Value
import org.springframework.cloud.gateway.route.RouteLocator
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder
import org.springframework.cloud.gateway.route.builder.filters
@@ -8,7 +9,9 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class GatewayConfig {
class GatewayConfig(
@Value("\${ping.service.url:http://localhost:8082}") private val pingServiceUrl: String
) {
@Bean
fun customRouteLocator(builder: RouteLocatorBuilder): RouteLocator {
@@ -22,7 +25,7 @@ class GatewayConfig {
it.fallbackUri = java.net.URI.create("forward:/fallback/ping")
}
}
uri("http://ping-service:8082")
uri(pingServiceUrl)
}
}
}
@@ -1,5 +1,5 @@
server:
port: 8081
port: ${GATEWAY_SERVER_PORT:8081}
spring:
application:
@@ -7,7 +7,6 @@ spring:
autoconfigure:
exclude:
- "org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration"
# --- VALKEY (für Rate Limiting) ---
data:
valkey:
@@ -18,8 +17,8 @@ spring:
# --- CONSUL (Service Discovery) ---
cloud:
consul:
host: ${CONSUL_HOST:localhost}
port: ${CONSUL_PORT:8500}
host: ${SPRING_CLOUD_CONSUL_HOST:localhost}
port: ${SPRING_CLOUD_CONSUL_PORT:8500}
discovery:
register: true
service-name: ${spring.application.name}
@@ -38,8 +37,8 @@ spring:
# Keycloak URL. Lokal: localhost:8080 (oder 8180 je nach Mapping).
# Im Docker: keycloak:8080.
# Wir nutzen hier localhost:8180 als Default (siehe docker-compose Port Mapping).
issuer-uri: ${KEYCLOAK_ISSUER_URI:http://localhost:8180/realms/meldestelle}
jwk-set-uri: ${KEYCLOAK_JWK_SET_URI:http://localhost:8180/realms/meldestelle/protocol/openid-connect/certs}
issuer-uri: ${SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI:http://localhost:8180/realms/meldestelle}
jwk-set-uri: ${SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI:http://localhost:8180/realms/meldestelle/protocol/openid-connect/certs}
management:
endpoints:
@@ -56,3 +55,10 @@ management:
probability: 1.0
propagation:
type: "w3c"
# --- Custom Service URLs ---
# Default: Localhost (für Entwicklung ohne Docker)
# Im Docker-Compose überschreiben wir das mit dem Service-Namen
ping:
service:
url: ${PING_SERVICE_URL:http://localhost:8082}
@@ -1,6 +1,6 @@
# Port, auf dem das Ping-Service läuft
server:
port: ${PING_SERVICE_PORT:8082}
port: ${PING_SERVER_PORT:8082}
spring:
application:
@@ -24,7 +24,7 @@ spring:
flyway:
enabled: true
# Erlaubt Migration auch wenn DB nicht leer ist (wichtig für Dev)
# Erlaubt die Migration, auch wenn DB nicht leer ist (wichtig für Dev)
baseline-on-migrate: true
# Sucht standardmäßig in classpath:db/migration
@@ -33,13 +33,13 @@ spring:
resourceserver:
jwt:
# Keycloak URL (lokal via Port Forwarding)
issuer-uri: ${KEYCLOAK_ISSUER_URI:http://localhost:8180/realms/meldestelle}
jwk-set-uri: ${KEYCLOAK_JWK_SET_URI:http://localhost:8180/realms/meldestelle/protocol/openid-connect/certs}
issuer-uri: ${SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI:http://localhost:8180/realms/meldestelle}
jwk-set-uri: ${SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI:http://localhost:8180/realms/meldestelle/protocol/openid-connect/certs}
cloud:
consul:
host: ${CONSUL_HOST:localhost}
port: ${CONSUL_PORT:8500}
host: ${SPRING_CLOUD_CONSUL_HOST:localhost}
port: ${SPRING_CLOUD_CONSUL_PORT:8500}
enabled: ${CONSUL_ENABLED:true}
discovery:
enabled: ${CONSUL_ENABLED:true}