meldestelle/docker-compose.services.yml
2025-08-17 00:15:29 +02:00

439 lines
16 KiB
YAML

# ===================================================================
# Docker Compose - Application Services
# Meldestelle Project - Service Layer Configuration
# ===================================================================
# Usage:
# Development: docker-compose -f docker-compose.yml -f docker-compose.services.yml up
# Production: docker-compose -f docker-compose.prod.yml -f docker-compose.services.yml up
# ===================================================================
# Optimized version with:
# - Standardized build arguments and environment variables
# - Enhanced health checks and resource constraints
# - Improved security configurations
# - Debug support and development features
# - Comprehensive monitoring and logging
# ===================================================================
version: '3.8'
services:
# ===================================================================
# Authentication Server
# ===================================================================
auth-server:
build:
context: .
dockerfile: dockerfiles/infrastructure/auth-server/Dockerfile
args:
GRADLE_VERSION: ${GRADLE_VERSION:-8.14}
JAVA_VERSION: ${JAVA_VERSION:-21}
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-docker}
APP_USER: ${AUTH_APP_USER:-authuser}
APP_UID: ${AUTH_APP_UID:-1002}
APP_GID: ${AUTH_APP_GID:-1002}
image: meldestelle/auth-server:latest
container_name: meldestelle-auth-server
ports:
- "${AUTH_SERVER_PORT:-8081}:8081"
- "${AUTH_DEBUG_PORT:-5005}:5005" # Debug port (conditional)
depends_on:
postgres:
condition: service_healthy
consul:
condition: service_healthy
redis:
condition: service_healthy
environment:
# Spring Boot Configuration
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-docker}
- SERVER_PORT=8081
- MANAGEMENT_SERVER_PORT=8081
- DEBUG=${DEBUG:-false}
# Service Discovery
- SPRING_CLOUD_CONSUL_HOST=consul
- SPRING_CLOUD_CONSUL_PORT=8500
- SPRING_APPLICATION_NAME=auth-server
# Database Configuration
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/${POSTGRES_DB:-meldestelle}
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-meldestelle}
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-meldestelle}
- SPRING_DATASOURCE_HIKARI_MAXIMUM_POOL_SIZE=${AUTH_DB_POOL_SIZE:-10}
- SPRING_DATASOURCE_HIKARI_MINIMUM_IDLE=${AUTH_DB_MIN_IDLE:-5}
# Redis Configuration
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PORT=6379
- SPRING_REDIS_PASSWORD=${REDIS_PASSWORD:-}
- SPRING_REDIS_TIMEOUT=${REDIS_TIMEOUT:-2000ms}
- SPRING_REDIS_LETTUCE_POOL_MAX_ACTIVE=${REDIS_POOL_MAX_ACTIVE:-8}
# Security Configuration
- JWT_SECRET=${JWT_SECRET:-meldestelle-auth-secret-key-change-in-production}
- JWT_EXPIRATION=${JWT_EXPIRATION:-86400}
- JWT_REFRESH_EXPIRATION=${JWT_REFRESH_EXPIRATION:-604800}
# Monitoring & Observability
- MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics,prometheus,configprops
- MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always
- MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=true
- MANAGEMENT_TRACING_SAMPLING_PROBABILITY=${TRACING_SAMPLING:-0.1}
- MANAGEMENT_ZIPKIN_TRACING_ENDPOINT=http://zipkin:9411/api/v2/spans
# Performance Tuning
- JAVA_OPTS=-XX:MaxRAMPercentage=75.0 -XX:+UseG1GC -XX:+UseStringDeduplication
- LOGGING_LEVEL_ROOT=${LOG_LEVEL:-INFO}
- LOGGING_LEVEL_AT_MOCODE=${APP_LOG_LEVEL:-DEBUG}
networks:
- meldestelle-network
volumes:
- auth-logs:/app/logs
- auth-temp:/app/tmp
healthcheck:
test: ["CMD", "curl", "-fsS", "--max-time", "3", "http://localhost:8081/actuator/health/readiness"]
interval: 15s
timeout: 5s
retries: 5
start_period: 60s
restart: unless-stopped
# Resource constraints
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
# Enhanced labels
labels:
- "traefik.enable=true"
- "traefik.http.routers.auth-server.rule=Host(`auth.meldestelle.local`)"
- "traefik.http.services.auth-server.loadbalancer.server.port=8081"
- "prometheus.scrape=true"
- "prometheus.port=8081"
- "prometheus.path=/actuator/prometheus"
- "prometheus.service=auth-server"
- "service.name=auth-server"
- "service.version=1.0.0"
- "service.environment=${SPRING_PROFILES_ACTIVE:-docker}"
# ===================================================================
# Monitoring Server
# ===================================================================
monitoring-server:
build:
context: .
dockerfile: dockerfiles/infrastructure/monitoring-server/Dockerfile
args:
GRADLE_VERSION: ${GRADLE_VERSION:-8.14}
JAVA_VERSION: ${JAVA_VERSION:-21}
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-docker}
image: meldestelle/monitoring-server:latest
container_name: meldestelle-monitoring-server
ports:
- "${MONITORING_SERVER_PORT:-8083}:8083"
- "${MONITORING_DEBUG_PORT:-5006}:5006" # Debug port
depends_on:
consul:
condition: service_healthy
prometheus:
condition: service_healthy
environment:
# Spring Boot Configuration
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-docker}
- SERVER_PORT=8083
- MANAGEMENT_SERVER_PORT=8083
- DEBUG=${DEBUG:-false}
# Service Discovery
- SPRING_CLOUD_CONSUL_HOST=consul
- SPRING_CLOUD_CONSUL_PORT=8500
- SPRING_APPLICATION_NAME=monitoring-server
# Monitoring Configuration
- PROMETHEUS_URL=http://prometheus:9090
- GRAFANA_URL=http://grafana:3000
- ZIPKIN_URL=http://zipkin:9411
- MONITORING_REFRESH_INTERVAL=${MONITORING_REFRESH_INTERVAL:-30s}
- MONITORING_ALERT_THRESHOLD=${MONITORING_ALERT_THRESHOLD:-0.8}
# Metrics Collection
- MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics,prometheus,env,configprops,beans
- MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always
- MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=true
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
- MANAGEMENT_TRACING_SAMPLING_PROBABILITY=${TRACING_SAMPLING:-0.1}
- MANAGEMENT_ZIPKIN_TRACING_ENDPOINT=http://zipkin:9411/api/v2/spans
# Performance Tuning
- JAVA_OPTS=-XX:MaxRAMPercentage=70.0 -XX:+UseG1GC -XX:+UseStringDeduplication
- LOGGING_LEVEL_ROOT=${LOG_LEVEL:-INFO}
- LOGGING_LEVEL_AT_MOCODE=${APP_LOG_LEVEL:-DEBUG}
- LOGGING_LEVEL_MICROMETER=DEBUG
- LOGGING_LEVEL_IO_MICROMETER=DEBUG
networks:
- meldestelle-network
volumes:
- monitoring-logs:/app/logs
- monitoring-temp:/app/tmp
- monitoring-data:/app/data
healthcheck:
test: ["CMD", "curl", "-fsS", "--max-time", "3", "http://localhost:8083/actuator/health/readiness"]
interval: 10s
timeout: 5s
retries: 3
start_period: 45s
restart: unless-stopped
# Resource constraints
deploy:
resources:
limits:
memory: 384M
cpus: '0.75'
# Enhanced labels
labels:
- "traefik.enable=true"
- "traefik.http.routers.monitoring-server.rule=Host(`monitoring.meldestelle.local`)"
- "traefik.http.services.monitoring-server.loadbalancer.server.port=8083"
- "prometheus.scrape=true"
- "prometheus.port=8083"
- "prometheus.path=/actuator/prometheus"
- "prometheus.service=monitoring-server"
- "service.name=monitoring-server"
- "service.version=1.0.0"
- "service.environment=${SPRING_PROFILES_ACTIVE:-docker}"
# ===================================================================
# API Gateway (Enhanced Configuration)
# ===================================================================
api-gateway:
build:
context: .
dockerfile: dockerfiles/infrastructure/gateway/Dockerfile
args:
GRADLE_VERSION: ${GRADLE_VERSION:-8.14}
JAVA_VERSION: ${JAVA_VERSION:-21}
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-docker}
image: meldestelle/api-gateway:latest
container_name: meldestelle-api-gateway
ports:
- "${API_GATEWAY_PORT:-8080}:8080"
- "${GATEWAY_DEBUG_PORT:-5007}:5007" # Debug port
depends_on:
consul:
condition: service_healthy
auth-server:
condition: service_healthy
environment:
# Spring Boot Configuration
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-docker}
- SERVER_PORT=8080
- DEBUG=${DEBUG:-false}
# Service Discovery
- SPRING_CLOUD_CONSUL_HOST=consul
- SPRING_CLOUD_CONSUL_PORT=8500
- SPRING_APPLICATION_NAME=api-gateway
# Gateway Configuration
- SPRING_CLOUD_GATEWAY_DISCOVERY_LOCATOR_ENABLED=true
- SPRING_CLOUD_GATEWAY_DISCOVERY_LOCATOR_LOWER_CASE_SERVICE_ID=true
- SPRING_CLOUD_GATEWAY_HTTPCLIENT_CONNECT_TIMEOUT=${GATEWAY_CONNECT_TIMEOUT:-5000}
- SPRING_CLOUD_GATEWAY_HTTPCLIENT_RESPONSE_TIMEOUT=${GATEWAY_RESPONSE_TIMEOUT:-30s}
- SPRING_CLOUD_GATEWAY_HTTPCLIENT_POOL_MAX_CONNECTIONS=${GATEWAY_POOL_MAX_CONNECTIONS:-100}
# Security Configuration
- AUTH_SERVER_URL=http://auth-server:8081
- JWT_SECRET=${JWT_SECRET:-meldestelle-auth-secret-key-change-in-production}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-http://localhost:3001,http://web-app}
- CORS_ALLOWED_METHODS=${CORS_ALLOWED_METHODS:-GET,POST,PUT,DELETE,OPTIONS}
# Circuit Breaker & Resilience
- RESILIENCE4J_CIRCUITBREAKER_INSTANCES_DEFAULT_SLIDING_WINDOW_SIZE=${CB_SLIDING_WINDOW:-10}
- RESILIENCE4J_CIRCUITBREAKER_INSTANCES_DEFAULT_FAILURE_RATE_THRESHOLD=${CB_FAILURE_RATE:-50}
- RESILIENCE4J_CIRCUITBREAKER_INSTANCES_DEFAULT_WAIT_DURATION_IN_OPEN_STATE=${CB_WAIT_DURATION:-60s}
- RESILIENCE4J_RETRY_INSTANCES_DEFAULT_MAX_ATTEMPTS=${RETRY_MAX_ATTEMPTS:-3}
- RESILIENCE4J_TIMELIMITER_INSTANCES_DEFAULT_TIMEOUT_DURATION=${TIMEOUT_DURATION:-10s}
# Rate Limiting
- SPRING_CLOUD_GATEWAY_FILTER_REQUEST_RATE_LIMITER_REDIS_RATE_LIMITER_REPLENISH_RATE=${RATE_LIMIT_REPLENISH:-10}
- SPRING_CLOUD_GATEWAY_FILTER_REQUEST_RATE_LIMITER_REDIS_RATE_LIMITER_BURST_CAPACITY=${RATE_LIMIT_BURST:-20}
# Monitoring & Observability
- MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics,prometheus,gateway,configprops
- MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always
- MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=true
- MANAGEMENT_TRACING_SAMPLING_PROBABILITY=${TRACING_SAMPLING:-0.1}
- MANAGEMENT_ZIPKIN_TRACING_ENDPOINT=http://zipkin:9411/api/v2/spans
# Performance Tuning
- JAVA_OPTS=-XX:MaxRAMPercentage=75.0 -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+OptimizeStringConcat
- LOGGING_LEVEL_ROOT=${LOG_LEVEL:-INFO}
- LOGGING_LEVEL_AT_MOCODE=${APP_LOG_LEVEL:-DEBUG}
- LOGGING_LEVEL_REACTOR_NETTY=${NETTY_LOG_LEVEL:-INFO}
networks:
- meldestelle-network
volumes:
- gateway-logs:/app/logs
- gateway-temp:/app/tmp
healthcheck:
test: ["CMD", "curl", "-fsS", "--max-time", "3", "http://localhost:8080/actuator/health/readiness"]
interval: 15s
timeout: 5s
retries: 3
start_period: 45s
restart: unless-stopped
# Resource constraints
deploy:
resources:
limits:
memory: 768M
cpus: '1.5'
# Enhanced labels
labels:
- "traefik.enable=true"
- "traefik.http.routers.api-gateway.rule=Host(`api.meldestelle.local`)"
- "traefik.http.services.api-gateway.loadbalancer.server.port=8080"
- "prometheus.scrape=true"
- "prometheus.port=8080"
- "prometheus.path=/actuator/prometheus"
- "prometheus.service=api-gateway"
- "service.name=api-gateway"
- "service.version=1.0.0"
- "service.environment=${SPRING_PROFILES_ACTIVE:-docker}"
# ===================================================================
# Ping Service (Enhanced for Integration Testing)
# ===================================================================
ping-service:
build:
context: .
dockerfile: dockerfiles/services/ping-service/Dockerfile
args:
GRADLE_VERSION: ${GRADLE_VERSION:-8.14}
JAVA_VERSION: ${JAVA_VERSION:-21}
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-docker}
image: meldestelle/ping-service:latest
container_name: meldestelle-ping-service
ports:
- "${PING_SERVICE_PORT:-8082}:8082"
- "${PING_DEBUG_PORT:-5008}:5008" # Debug port
depends_on:
consul:
condition: service_healthy
environment:
# Spring Boot Configuration
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-docker}
- SERVER_PORT=8082
- DEBUG=${DEBUG:-false}
# Service Discovery
- SPRING_CLOUD_CONSUL_HOST=consul
- SPRING_CLOUD_CONSUL_PORT=8500
- SPRING_APPLICATION_NAME=ping-service
# Integration Testing Configuration
- PING_TEST_INTERVAL=${PING_TEST_INTERVAL:-30s}
- PING_TIMEOUT=${PING_TIMEOUT:-5s}
- PING_MAX_RETRIES=${PING_MAX_RETRIES:-3}
- INTEGRATION_TEST_ENABLED=${INTEGRATION_TEST_ENABLED:-true}
# Monitoring & Observability
- MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics,prometheus,configprops
- MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always
- MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=true
- MANAGEMENT_TRACING_SAMPLING_PROBABILITY=${TRACING_SAMPLING:-0.1}
- MANAGEMENT_ZIPKIN_TRACING_ENDPOINT=http://zipkin:9411/api/v2/spans
# Performance Tuning
- JAVA_OPTS=-XX:MaxRAMPercentage=60.0 -XX:+UseG1GC -XX:+UseStringDeduplication
- LOGGING_LEVEL_ROOT=${LOG_LEVEL:-INFO}
- LOGGING_LEVEL_AT_MOCODE=${APP_LOG_LEVEL:-DEBUG}
- LOGGING_LEVEL_SPRING_WEB=${WEB_LOG_LEVEL:-INFO}
networks:
- meldestelle-network
volumes:
- ping-logs:/app/logs
- ping-temp:/app/tmp
healthcheck:
test: ["CMD", "curl", "-fsS", "--max-time", "3", "http://localhost:8082/actuator/health/readiness"]
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
restart: unless-stopped
# Resource constraints (lightweight service)
deploy:
resources:
limits:
memory: 256M
cpus: '0.5'
# Enhanced labels
labels:
- "traefik.enable=true"
- "traefik.http.routers.ping-service.rule=Host(`ping.meldestelle.local`)"
- "traefik.http.services.ping-service.loadbalancer.server.port=8082"
- "prometheus.scrape=true"
- "prometheus.port=8082"
- "prometheus.path=/actuator/prometheus"
- "prometheus.service=ping-service"
- "service.name=ping-service"
- "service.version=1.0.0"
- "service.environment=${SPRING_PROFILES_ACTIVE:-docker}"
# ===================================================================
# Volumes for Service Data, Logs, and Temporary Files
# ===================================================================
volumes:
# Authentication Server
auth-logs:
driver: local
driver_opts:
type: none
o: bind
device: ./logs/auth-server
auth-temp:
driver: local
# Monitoring Server
monitoring-logs:
driver: local
driver_opts:
type: none
o: bind
device: ./logs/monitoring-server
monitoring-temp:
driver: local
monitoring-data:
driver: local
driver_opts:
type: none
o: bind
device: ./data/monitoring-server
# API Gateway
gateway-logs:
driver: local
driver_opts:
type: none
o: bind
device: ./logs/api-gateway
gateway-temp:
driver: local
# Ping Service
ping-logs:
driver: local
driver_opts:
type: none
o: bind
device: ./logs/ping-service
ping-temp:
driver: local
# ===================================================================
# Networks (inherits from main docker-compose.yml)
# ===================================================================
networks:
meldestelle-network:
driver: bridge