# 本项目后端所需中间件，开箱即用
name: easyflow-middleware

services:
  mysql:
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/mysql:8.0.36-linuxarm64
    container_name: easyflow-mysql
    restart: unless-stopped
    command:
      - --default-authentication-plugin=mysql_native_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --max_connections=500
      - --sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: easyflow
      MYSQL_USER: easyflow
      MYSQL_PASSWORD: "123456"
    ports:
      - "3306:3306"
    volumes:
      - ./data/mysql:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s

  redis:
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/kubesphere/redis:7.2.4-alpine-linuxarm64
    container_name: easyflow-redis
    restart: unless-stopped
    command: ["redis-server", "--appendonly", "yes", "--requirepass", "123456"]
    ports:
      - "6379:6379"
    volumes:
      - ./data/redis:/data
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "123456", "ping"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 10s

  etcd:
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/quay.io/coreos/etcd:v3.5.5-linuxarm64
    container_name: easyflow-etcd
    restart: unless-stopped
    environment:
      TZ: Asia/Shanghai
      ETCD_AUTO_COMPACTION_MODE: revision
      ETCD_AUTO_COMPACTION_RETENTION: "1000"
      ETCD_QUOTA_BACKEND_BYTES: "4294967296"
      ETCD_SNAPSHOT_COUNT: "50000"
    command:
      - /usr/local/bin/etcd
      - --advertise-client-urls=http://0.0.0.0:2379
      - --listen-client-urls=http://0.0.0.0:2379
      - --data-dir=/etcd
    volumes:
      - ./data/etcd:/etcd

  minio:
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/quay.io/minio/minio:RELEASE.2025-07-23T15-54-02Z-linuxarm64
    container_name: easyflow-minio
    restart: unless-stopped
    command: server /data --address ":9000" --console-address ":9001"
    environment:
      TZ: Asia/Shanghai
      MINIO_ROOT_USER: easyflowadmin
      MINIO_ROOT_PASSWORD: easyflowadmin123
      MINIO_API_STALE_UPLOADS_EXPIRY: 24h
      MINIO_API_STALE_UPLOADS_CLEANUP_INTERVAL: 6h
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - ./data/minio:/data

  minio-init:
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/minio/mc:RELEASE.2024-09-16T17-43-14Z-linuxarm64
    container_name: easyflow-minio-init
    restart: "no"
    depends_on:
      - minio
    environment:
      MINIO_ROOT_USER: easyflowadmin
      MINIO_ROOT_PASSWORD: easyflowadmin123
      MINIO_ENDPOINT: http://minio:9000
      MINIO_BUCKETS: easyflow,milvus,easyflow-agent-media
      MINIO_PUBLIC_BUCKETS: easyflow
      MINIO_ALIAS: local
    volumes:
      - ./scripts/minio/init-minio.sh:/scripts/init-minio.sh:ro
    entrypoint: ["/bin/sh", "/scripts/init-minio.sh"]

  milvus:
    image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/milvusdb/milvus:v2.3.3-linuxarm64
    container_name: easyflow-milvus
    restart: unless-stopped
    command: ["milvus", "run", "standalone"]
    security_opt:
      - seccomp:unconfined
    environment:
      ETCD_ENDPOINTS: etcd:2379
      COMMON_STORAGETYPE: minio
      MINIO_ADDRESS: minio:9000
      MINIO_ACCESS_KEY_ID: easyflowadmin
      MINIO_SECRET_ACCESS_KEY: easyflowadmin123
      MINIO_USE_SSL: "false"
      MINIO_BUCKET_NAME: milvus
    depends_on:
      etcd:
        condition: service_started
      minio:
        condition: service_started
      minio-init:
        condition: service_completed_successfully
    ports:
      - "39530:19530"
      - "9091:9091"
    volumes:
      - ./data/milvus:/var/lib/milvus

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.15.5
    container_name: easyflow-elasticsearch
    restart: unless-stopped
    environment:
      TZ: Asia/Shanghai
      discovery.type: single-node
      ELASTIC_PASSWORD: elastic
      xpack.security.enabled: "true"
      ES_JAVA_OPTS: -Xms1g -Xmx1g
    ports:
      - "39200:9200"
    volumes:
      - ./data/elasticsearch:/usr/share/elasticsearch/data
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "curl -fsS -u elastic:elastic http://127.0.0.1:9200 >/dev/null || exit 1",
        ]
      interval: 15s
      timeout: 10s
      retries: 20
      start_period: 60s
