# =================================================================== # 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: 5 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: 10s restart: unless-stopped # =================================================================== # Authentifizierung # =================================================================== keycloak: image: quay.io/keycloak/keycloak:23.0 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", "curl", "--fail", "http://localhost:8080/health/ready" ] interval: 10s timeout: 5s retries: 5 start_period: 30s 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: 15s 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:8080/actuator/health" ] interval: 10s timeout: 5s retries: 5 start_period: 30s restart: unless-stopped # =================================================================== # Volumes # =================================================================== volumes: postgres-data: driver: local redis-data: driver: local # =================================================================== # Networks # =================================================================== networks: meldestelle-network: driver: bridge