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

services:
  milvus-standalone-embed:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}milvusdb/milvus:${MILVUS_VERSION:-v2.6.7}
    security_opt:
      - seccomp:unconfined
    environment:
      TZ: ${TZ:-UTC}
      ETCD_USE_EMBED: 'true'
      ETCD_DATA_DIR: /var/lib/milvus/etcd
      ETCD_CONFIG_PATH: /milvus/configs/embed_etcd.yaml
      COMMON_STORAGETYPE: local
      DEPLOY_MODE: STANDALONE
    volumes:
      - milvus_data:/var/lib/milvus
      - ./embed_etcd.yaml:/milvus/configs/embed_etcd.yaml
      - ./user.yaml:/milvus/configs/user.yaml
    ports:
      - '${MILVUS_PORT_OVERRIDE_HTTP:-19530}:19530'
      - '${MILVUS_PORT_OVERRIDE_WEBUI:-9091}:9091'
      - '${MILVUS_PORT_OVERRIDE_ETCD:-2379}:2379'
    healthcheck:
      test: [CMD, curl, -f, 'http://localhost:9091/healthz']
      interval: 30s
      start_period: 90s
      timeout: 20s
      retries: 3
    command: [milvus, run, standalone]
    deploy:
      resources:
        limits:
          cpus: ${MILVUS_EMBED_CPU_LIMIT:-2.0}
          memory: ${MILVUS_EMBED_MEMORY_LIMIT:-4G}
        reservations:
          cpus: ${MILVUS_EMBED_CPU_RESERVATION:-1.0}
          memory: ${MILVUS_EMBED_MEMORY_RESERVATION:-2G}

  attu:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}zilliz/attu:${ATTU_VERSION:-v2.6.4}
    profiles:
      - attu
    environment:
      TZ: ${TZ:-UTC}
      MILVUS_URL: ${MILVUS_URL:-milvus-standalone-embed:19530}
    ports:
      - '${ATTU_OVERRIDE_PORT:-8000}:3000'
    depends_on:
      milvus-standalone-embed:
        condition: service_healthy
    deploy:
      resources:
        limits:
          cpus: ${ATTU_CPU_LIMIT:-0.25}
          memory: ${ATTU_MEMORY_LIMIT:-256M}
        reservations:
          cpus: ${ATTU_CPU_RESERVATION:-0.1}
          memory: ${ATTU_MEMORY_RESERVATION:-128M}
    healthcheck:
      test:
        - CMD
        - wget
        - --no-verbose
        - --tries=1
        - --spider
        - 'http://localhost:3000/'

      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

volumes:
  milvus_data:
