event-service 0.2.0

Event Service - An event administration microservice that interoperates with the event-matcher crate
version: "3.8"

services:
  # PostgreSQL database
  postgres:
    image: postgres:18-alpine
    container_name: mpi-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-mpi}
      POSTGRES_USER: ${POSTGRES_USER:-mpi_user}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-mpi_password}
      POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "pg_isready -U ${POSTGRES_USER:-mpi_user} -d ${POSTGRES_DB:-mpi}",
        ]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - mpi-network

  # Event Service application
  mpi-server:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: mpi-server
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      # Database configuration
      DATABASE_URL: postgresql://${POSTGRES_USER:-mpi_user}:${POSTGRES_PASSWORD:-mpi_password}@postgres:5432/${POSTGRES_DB:-mpi}
      DATABASE_MAX_CONNECTIONS: ${DATABASE_MAX_CONNECTIONS:-10}
      DATABASE_MIN_CONNECTIONS: ${DATABASE_MIN_CONNECTIONS:-2}

      # Server configuration
      SERVER_HOST: 0.0.0.0
      SERVER_PORT: 8080

      # Search configuration
      SEARCH_INDEX_PATH: /app/data/search_index

      # Matching configuration
      MATCHING_THRESHOLD: ${MATCHING_THRESHOLD:-0.7}
      MATCHING_NAME_WEIGHT: ${MATCHING_NAME_WEIGHT:-0.4}
      MATCHING_DOB_WEIGHT: ${MATCHING_DOB_WEIGHT:-0.3}
      MATCHING_GENDER_WEIGHT: ${MATCHING_GENDER_WEIGHT:-0.1}
      MATCHING_ADDRESS_WEIGHT: ${MATCHING_ADDRESS_WEIGHT:-0.2}

      # Logging
      RUST_LOG: ${RUST_LOG:-info}
      RUST_BACKTRACE: ${RUST_BACKTRACE:-0}
    ports:
      - "${MPI_PORT:-8080}:8080"
    volumes:
      - search_index:/app/data/search_index
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    networks:
      - mpi-network

  # pgAdmin for database management (optional)
  pgadmin:
    image: dpage/pgadmin4:latest
    container_name: mpi-pgadmin
    restart: unless-stopped
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL:-admin@mpi.local}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD:-admin}
      PGADMIN_LISTEN_PORT: 80
    ports:
      - "${PGADMIN_PORT:-5050}:80"
    volumes:
      - pgadmin_data:/var/lib/pgadmin
    networks:
      - mpi-network
    profiles:
      - tools # Only start with --profile tools

volumes:
  postgres_data:
    driver: local
  search_index:
    driver: local
  pgadmin_data:
    driver: local

networks:
  mpi-network:
    driver: bridge