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

services:
  metad:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}vesoft/nebula-metad:${NEBULA_VERSION:-v3.8.0}
    environment:
      - TZ=${TZ:-UTC}
      - USER=root
    command:
      - --meta_server_addrs=metad:9559
      - --local_ip=metad
      - --ws_ip=metad
      - --port=9559
      - --data_path=/data/meta
      - --log_dir=/logs
    volumes:
      - nebula_meta_data:/data/meta
      - nebula_meta_logs:/logs
    ports:
      - '9559:9559'
      - '19559:19559'
      - '19560:19560'
    deploy:
      resources:
        limits:
          cpus: ${NEBULA_METAD_CPU_LIMIT:-0.5}
          memory: ${NEBULA_METAD_MEMORY_LIMIT:-512M}
        reservations:
          cpus: ${NEBULA_METAD_CPU_RESERVATION:-0.1}
          memory: ${NEBULA_METAD_MEMORY_RESERVATION:-256M}
    healthcheck:
      test: [CMD, /usr/local/nebula/bin/nebula-metad, --version]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  storaged:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}vesoft/nebula-storaged:${NEBULA_VERSION:-v3.8.0}
    environment:
      - TZ=${TZ:-UTC}
      - USER=root
    command:
      - --meta_server_addrs=metad:9559
      - --local_ip=storaged
      - --ws_ip=storaged
      - --port=9779
      - --data_path=/data/storage
      - --log_dir=/logs
    depends_on:
      metad:
        condition: service_healthy
    volumes:
      - nebula_storage_data:/data/storage
      - nebula_storage_logs:/logs
    ports:
      - '9779:9779'
      - '19779:19779'
      - '19780:19780'
    deploy:
      resources:
        limits:
          cpus: ${NEBULA_STORAGED_CPU_LIMIT:-1.0}
          memory: ${NEBULA_STORAGED_MEMORY_LIMIT:-1G}
        reservations:
          cpus: ${NEBULA_STORAGED_CPU_RESERVATION:-0.1}
          memory: ${NEBULA_STORAGED_MEMORY_RESERVATION:-512M}
    healthcheck:
      test: [CMD, /usr/local/nebula/bin/nebula-storaged, --version]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  graphd:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}vesoft/nebula-graphd:${NEBULA_VERSION:-v3.8.0}
    environment:
      - TZ=${TZ:-UTC}
      - USER=root
    command:
      - --meta_server_addrs=metad:9559
      - --port=9669
      - --local_ip=graphd
      - --ws_ip=graphd
      - --log_dir=/logs
    depends_on:
      metad:
        condition: service_healthy
      storaged:
        condition: service_healthy
    volumes:
      - nebula_graph_logs:/logs
    ports:
      - '${NEBULA_GRAPHD_PORT_OVERRIDE:-9669}:9669'
      - '19669:19669'
      - '19670:19670'
    deploy:
      resources:
        limits:
          cpus: ${NEBULA_GRAPHD_CPU_LIMIT:-1.0}
          memory: ${NEBULA_GRAPHD_MEMORY_LIMIT:-1G}
        reservations:
          cpus: ${NEBULA_GRAPHD_CPU_RESERVATION:-0.1}
          memory: ${NEBULA_GRAPHD_MEMORY_RESERVATION:-512M}
    healthcheck:
      test: [CMD, /usr/local/nebula/bin/nebula-graphd, --version]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

volumes:
  nebula_meta_data:
  nebula_meta_logs:
  nebula_storage_data:
  nebula_storage_logs:
  nebula_graph_logs:
