257 lines
8.1 KiB
YAML
257 lines
8.1 KiB
YAML
# ===================================================================
|
|
# Docker Compose - Basis-Infrastruktur
|
|
# Meldestelle Project - Essentielle Services
|
|
# ===================================================================
|
|
# Usage:
|
|
# Entwicklung & Standard: docker-compose up -d
|
|
# ===================================================================
|
|
|
|
services:
|
|
# ===================================================================
|
|
# Datenbank
|
|
# ===================================================================
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: meldestelle-postgres
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-meldestelle}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-meldestelle}
|
|
POSTGRES_DB: ${POSTGRES_DB:-meldestelle}
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- postgres-data:/var/lib/postgresql/data
|
|
- ./docker/services/postgres:/docker-entrypoint-initdb.d
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: [ "CMD-SHELL", "pg_isready -U meldestelle -d meldestelle" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Cache
|
|
# ===================================================================
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: meldestelle-redis
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
volumes:
|
|
- redis-data:/data
|
|
command: redis-server --appendonly yes
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: [ "CMD", "redis-cli", "ping" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Authentifizierung
|
|
# ===================================================================
|
|
keycloak:
|
|
image: quay.io/keycloak/keycloak:25.0.6
|
|
container_name: meldestelle-keycloak
|
|
environment:
|
|
KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN:-admin}
|
|
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-admin}
|
|
KC_DB: postgres
|
|
KC_DB_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB:-meldestelle}
|
|
KC_DB_USERNAME: ${POSTGRES_USER:-meldestelle}
|
|
KC_DB_PASSWORD: ${POSTGRES_PASSWORD:-meldestelle}
|
|
ports:
|
|
- "8180:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./docker/services/keycloak:/opt/keycloak/data/import
|
|
command: start-dev --import-realm
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Service Discovery
|
|
# ===================================================================
|
|
consul:
|
|
image: hashicorp/consul:1.15
|
|
container_name: meldestelle-consul
|
|
ports:
|
|
- "${CONSUL_PORT:-8500}:8500"
|
|
command: agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: [ "CMD", "curl", "-f", "http://localhost:8500/v1/status/leader" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Messaging (Kafka & Zookeeper)
|
|
# ===================================================================
|
|
zookeeper:
|
|
image: confluentinc/cp-zookeeper:7.4.0
|
|
container_name: meldestelle-zookeeper
|
|
environment:
|
|
ZOOKEEPER_CLIENT_PORT: ${ZOOKEEPER_CLIENT_PORT:-2181}
|
|
ZOOKEEPER_TICK_TIME: 2000
|
|
ports:
|
|
- "${ZOOKEEPER_CLIENT_PORT:-2181}:2181"
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: ["CMD", "bash", "-c", "echo 'ruok' | nc localhost 2181"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
kafka:
|
|
image: confluentinc/cp-kafka:7.4.0
|
|
container_name: meldestelle-kafka
|
|
environment:
|
|
KAFKA_BROKER_ID: ${KAFKA_BROKER_ID:-1}
|
|
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
|
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:${KAFKA_PORT:-9092}
|
|
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
|
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: ${KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR:-1}
|
|
ports:
|
|
- "${KAFKA_PORT:-9092}:9092"
|
|
depends_on:
|
|
zookeeper:
|
|
condition: service_healthy
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Monitoring (Prometheus & Grafana)
|
|
# ===================================================================
|
|
prometheus:
|
|
image: prom/prometheus:v2.47.0
|
|
container_name: meldestelle-prometheus
|
|
ports:
|
|
- "${PROMETHEUS_PORT:-9090}:9090"
|
|
volumes:
|
|
- prometheus-data:/prometheus
|
|
- ./docker/monitoring/prometheus:/etc/prometheus:ro
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
- '--web.console.templates=/etc/prometheus/consoles'
|
|
- '--storage.tsdb.retention.time=200h'
|
|
- '--web.enable-lifecycle'
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
grafana:
|
|
image: grafana/grafana:10.1.0
|
|
container_name: meldestelle-grafana
|
|
environment:
|
|
GF_SECURITY_ADMIN_USER: ${GF_SECURITY_ADMIN_USER:-admin}
|
|
GF_SECURITY_ADMIN_PASSWORD: ${GF_SECURITY_ADMIN_PASSWORD:-admin}
|
|
GF_USERS_ALLOW_SIGN_UP: ${GF_USERS_ALLOW_SIGN_UP:-false}
|
|
GF_INSTALL_PLUGINS: grafana-piechart-panel
|
|
ports:
|
|
- "${GRAFANA_PORT:-3000}:3000"
|
|
volumes:
|
|
- grafana-data:/var/lib/grafana
|
|
- ./docker/monitoring/grafana:/etc/grafana/provisioning:ro
|
|
depends_on:
|
|
- prometheus
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "--fail", "http://localhost:3000/api/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# API Gateway
|
|
# ===================================================================
|
|
api-gateway:
|
|
build:
|
|
context: .
|
|
dockerfile: infrastructure/gateway/Dockerfile
|
|
container_name: meldestelle-api-gateway
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-dev}
|
|
CONSUL_HOST: consul
|
|
CONSUL_PORT: ${CONSUL_PORT:-8500}
|
|
CONSUL_ENABLED: "true"
|
|
GATEWAY_PORT: ${GATEWAY_PORT:-8081}
|
|
ports:
|
|
- "${GATEWAY_PORT:-8081}:${GATEWAY_PORT:-8081}"
|
|
depends_on:
|
|
consul:
|
|
condition: service_healthy
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
networks:
|
|
- meldestelle-network
|
|
healthcheck:
|
|
test: [ "CMD", "curl", "--fail", "http://localhost:${GATEWAY_PORT:-8081}/actuator/health" ]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 30s
|
|
restart: unless-stopped
|
|
|
|
# ===================================================================
|
|
# Volumes
|
|
# ===================================================================
|
|
volumes:
|
|
postgres-data:
|
|
driver: local
|
|
redis-data:
|
|
driver: local
|
|
prometheus-data:
|
|
driver: local
|
|
grafana-data:
|
|
driver: local
|
|
|
|
# ===================================================================
|
|
# Networks
|
|
# ===================================================================
|
|
networks:
|
|
meldestelle-network:
|
|
driver: bridge
|