services:
  eddi:
    image: labsai/eddi:${EDDI_VERSION:-latest}
    environment:
      - "EDDI_VAULT_MASTER_KEY=${EDDI_VAULT_MASTER_KEY:-}"
      - "EDDI_DATASTORE_TYPE=${EDDI_DATASTORE_TYPE:-mongodb}"
      - "EDDI_SECURITY_ALLOW_UNAUTHENTICATED=true"
      - "MONGODB_CONNECTIONSTRING=mongodb://${MONGO_INITDB_ROOT_USERNAME:-eddi}:${MONGO_INITDB_ROOT_PASSWORD:-changeme}@mongodb:27017/eddi?authSource=admin&retryWrites=true&w=majority&connectTimeoutMS=10000&socketTimeoutMS=30000"
#      - "JAVA_OPTS_APPEND=-Dquarkus.http.cors.origins=http://localhost:3000"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "${EDDI_PORT:-7070}:7070"
      - "${EDDI_HTTPS_PORT:-7443}:7443"
#      - "5005:5005"
    depends_on:
      mongodb:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7070/q/health/ready"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s

  mongodb:
    image: mongo:7.0.14
    restart: always
    environment:
      - "MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME:-eddi}"
      - "MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD:-changeme}"
    ports:
      - "127.0.0.1:${MONGO_PORT:-27017}:27017"
    volumes:
      - mongodb-db:/data/db
    healthcheck:
      test: ["CMD", "mongosh", "-u", "${MONGO_INITDB_ROOT_USERNAME:-eddi}", "-p", "${MONGO_INITDB_ROOT_PASSWORD:-changeme}", "--authenticationDatabase", "admin", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

volumes:
  mongodb-db:
