# Apache Doris Docker Compose
# Doris is an OLAP database for modern analytics
# Provides standalone mode with FE and BE nodes for development/testing

x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  # Doris Frontend (FE) node
  doris-fe:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}apache/doris:${DORIS_VERSION:-3.0.0}-fe-x86_64
    hostname: doris-fe
    ports:
      - '${DORIS_FE_QUERY_PORT_OVERRIDE:-9030}:9030'
      - '${DORIS_FE_HTTP_PORT_OVERRIDE:-8030}:8030'
      - '${DORIS_FE_RPC_PORT_OVERRIDE:-9020}:9020'
      - '${DORIS_FE_EDIT_LOG_PORT_OVERRIDE:-9010}:9010'
    volumes:
      - doris_fe_data:/opt/apache-doris/fe/doris-meta
    environment:
      - TZ=${TZ:-UTC}
      - FE_SERVERS=doris-fe:9010
      - FRONTEND_REPLICAS=1
    healthcheck:
      test: [CMD-SHELL, 'curl -sf http://localhost:8030/api/v2/system/info || exit 1']
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s
    deploy:
      resources:
        limits:
          cpus: ${DORIS_FE_CPU_LIMIT:-1.00}
          memory: ${DORIS_FE_MEMORY_LIMIT:-2G}
        reservations:
          cpus: ${DORIS_FE_CPU_RESERVATION:-0.50}
          memory: ${DORIS_FE_MEMORY_RESERVATION:-1G}

  # Doris Backend (BE) node
  doris-be:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}apache/doris:${DORIS_VERSION:-3.0.0}-be-x86_64
    hostname: doris-be
    ports:
      - '${DORIS_BE_HEARTBEAT_PORT_OVERRIDE:-9050}:9050'
      - '${DORIS_BE_THRIFT_RPC_PORT_OVERRIDE:-9060}:9060'
      - '${DORIS_BE_HTTP_PORT_OVERRIDE:-8040}:8040'
    volumes:
      - doris_be_data:/opt/apache-doris/be/storage
    environment:
      - TZ=${TZ:-UTC}
      - FE_SERVERS=doris-fe:9010
    depends_on:
      doris-fe:
        condition: service_healthy
    healthcheck:
      test: [CMD-SHELL, 'curl -sf http://localhost:8040/api/health || exit 1']
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s
    deploy:
      resources:
        limits:
          cpus: ${DORIS_BE_CPU_LIMIT:-2.00}
          memory: ${DORIS_BE_MEMORY_LIMIT:-4G}
        reservations:
          cpus: ${DORIS_BE_CPU_RESERVATION:-1.00}
          memory: ${DORIS_BE_MEMORY_RESERVATION:-2G}

volumes:
  doris_fe_data:
  doris_be_data:
