version: '3.8'

services:
  langfuse-db:
    image: postgres:15
    container_name: langfuse-postgres
    environment:
      POSTGRES_USER: hellotax
      POSTGRES_PASSWORD: ${LANGFUSE_DB_PASSWORD:-YjmayiHEzxBGtoB7KQaZW1s1LAg97qRMJgB0U9rZUow}
      POSTGRES_DB: langfuse
    ports:
      - "5436:5432"
    volumes:
      - langfuse-db-data:/var/lib/postgresql/data
    restart: unless-stopped

  langfuse-clickhouse:
    image: clickhouse/clickhouse-server:24
    container_name: langfuse-clickhouse
    environment:
      CLICKHOUSE_DB: default
      CLICKHOUSE_USER: hellotax
      CLICKHOUSE_PASSWORD: NUSQkTqdjJBCtLr97YO4U-kGEkbF_CQSmrLWJHzo24Q
    ports:
      - "8123:8123"
      - "9002:9000"
    volumes:
      - langfuse-ch-data:/var/lib/clickhouse
    restart: unless-stopped

  langfuse-minio:
    image: minio/minio:latest
    container_name: langfuse-minio
    command: server /data --console-address ":9091"
    environment:
      MINIO_ROOT_USER: hellotax
      MINIO_ROOT_PASSWORD: NR2BdjnpMu0IeuoWl4SWW5dP4uzXkjKXHEx_7aAfpnQ
    ports:
      - "9003:9000"
      - "9091:9091"
    volumes:
      - langfuse-minio-data:/data
    restart: unless-stopped

  langfuse-minio-init:
    image: minio/mc:latest
    container_name: langfuse-minio-init
    depends_on:
      - langfuse-minio
    entrypoint: >
      /bin/sh -c "
      sleep 5;
      mc alias set local http://langfuse-minio:9000 hellotax NR2BdjnpMu0IeuoWl4SWW5dP4uzXkjKXHEx_7aAfpnQ;
      mc mb --ignore-existing local/langfuse-events;
      mc mb --ignore-existing local/langfuse-media;
      exit 0;
      "
    restart: "no"

  langfuse-web:
    image: langfuse/langfuse:latest
    container_name: langfuse-web
    depends_on:
      - langfuse-db
      - langfuse-clickhouse
      - langfuse-minio
    ports:
      - "3150:3000"
    environment:
      DATABASE_URL: postgresql://hellotax:${LANGFUSE_DB_PASSWORD:-YjmayiHEzxBGtoB7KQaZW1s1LAg97qRMJgB0U9rZUow}@langfuse-db:5432/langfuse
      CLICKHOUSE_URL: http://langfuse-clickhouse:8123
      CLICKHOUSE_MIGRATION_URL: clickhouse://langfuse-clickhouse:9000
      CLICKHOUSE_USER: hellotax
      CLICKHOUSE_PASSWORD: NUSQkTqdjJBCtLr97YO4U-kGEkbF_CQSmrLWJHzo24Q
      CLICKHOUSE_CLUSTER_ENABLED: "false"
      LANGFUSE_S3_EVENT_UPLOAD_BUCKET: langfuse-events
      LANGFUSE_S3_EVENT_UPLOAD_REGION: us-east-1
      LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT: http://langfuse-minio:9000
      LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID: hellotax
      LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY: NR2BdjnpMu0IeuoWl4SWW5dP4uzXkjKXHEx_7aAfpnQ
      LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE: "true"
      LANGFUSE_S3_MEDIA_UPLOAD_BUCKET: langfuse-media
      LANGFUSE_S3_MEDIA_UPLOAD_REGION: us-east-1
      LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT: http://langfuse-minio:9000
      LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_ID: hellotax
      LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY: NR2BdjnpMu0IeuoWl4SWW5dP4uzXkjKXHEx_7aAfpnQ
      LANGFUSE_S3_MEDIA_UPLOAD_FORCE_PATH_STYLE: "true"
      NEXTAUTH_URL: http://localhost:3150
      NEXTAUTH_SECRET: ${LANGFUSE_NEXTAUTH_SECRET:-changeme-in-production}
      SALT: ${LANGFUSE_SALT:-changeme-in-production}
    restart: unless-stopped

volumes:
  langfuse-db-data:
  langfuse-ch-data:
  langfuse-minio-data:
