services:
  supersonic_postgres:
    image: pgvector/pgvector:pg17
    privileged: true
    container_name: supersonic_postgres
    environment:
      LANG: 'C.UTF-8'  # 设置环境变量
      POSTGRES_ROOT_PASSWORD: root_password
      POSTGRES_DATABASE: postgres
      POSTGRES_USER: supersonic_user
      POSTGRES_PASSWORD: supersonic_password
    ports:
      - "15432:5432"
    volumes:
       - ./supersonic_pg/data:/var/lib/postgresql/data
    networks:
      - supersonic_network
    dns:
      - 114.114.114.114
      - 8.8.8.8
      - 8.8.4.4
    healthcheck:
      test: ["CMD-SHELL", "sh -c 'pg_isready -U supersonic_user -d postgres'"]
      interval: 10s
      timeout: 10s
      retries: 5

  supersonic_standalone:
    image: supersonicbi/supersonic:${SUPERSONIC_VERSION:-latest}
    privileged: true
    container_name: supersonic_standalone
    environment:
      S2_DB_TYPE: postgres
      S2_DB_HOST: supersonic_postgres
      S2_DB_PORT: 5432
      S2_DB_DATABASE: postgres
      S2_DB_USER: supersonic_user
      S2_DB_PASSWORD: supersonic_password
    ports:
      - "9080:9080"
    deploy:
      resources:
        limits:
          cpus: "2.0"
          memory: 2048M
    depends_on:
      supersonic_postgres:
        condition: service_healthy
    networks:
      - supersonic_network
    dns:
      - 114.114.114.114
      - 8.8.8.8
      - 8.8.4.4
    #volumes:
      #1.Named Volumes are best for persistent data managed by Docker.
      #- supersonic_data:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}
      #2.Bind Mounts are suitable for frequent modifications and debugging.
      #      - ./conf/application-prd.yaml:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}/conf/application-prd.yaml
      #3.Detailed Bind Mounts offer more control over the mount behavior.
      #      - type: bind
      #        source: ./supersonic-standalone-${SUPERSONIC_VERSION:-latest}/logs
      #        target: /usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}/logs
      #        bind:
      #          propagation: rprivate
      #          create_host_path: true
#volumes:
#  supersonic_data:

networks:
  supersonic_network:
