name: dify
services:
  config:
    container_name: dify-config
    restart: unless-stopped
    image: ns2kracy/dify-config:latest
    volumes:
      - type: bind
        source: /DATA/AppData/$AppID/data/nginx
        target: /configs/nginx
      - type: bind
        source: /DATA/AppData/$AppID/data/ssrf_proxy
        target: /configs/ssrf_proxy
      - type: bind
        source: /DATA/AppData/$AppID/data/sandbox
        target: /configs/sandbox
    networks:
      - dify

  api:
    image: langgenius/dify-api:0.12.1
    container_name: dify-api
    restart: unless-stopped
    environment:
      MODE: api
      LOG_LEVEL: INFO
      SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
      CONSOLE_WEB_URL: ""
      INIT_PASSWORD: ""
      CONSOLE_API_URL: ""
      SERVICE_API_URL: ""
      APP_WEB_URL: ""
      FILES_URL: ""
      FILES_ACCESS_TIMEOUT: "300"
      MIGRATION_ENABLED: "true"
      DB_USERNAME: postgres
      DB_PASSWORD: difyai123456
      DB_HOST: db
      DB_PORT: "5432"
      DB_DATABASE: dify
      REDIS_HOST: redis
      REDIS_PORT: "6379"
      REDIS_PASSWORD: difyai123456
      REDIS_DB: "0"
      CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
      WEB_API_CORS_ALLOW_ORIGINS: "*"
      CONSOLE_CORS_ALLOW_ORIGINS: "*"
      STORAGE_TYPE: local
      STORAGE_LOCAL_PATH: storage
      VECTOR_STORE: weaviate
      WEAVIATE_ENDPOINT: http://weaviate:8080
      WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
      CODE_EXECUTION_ENDPOINT: "http://sandbox:8194"
      CODE_EXECUTION_API_KEY: dify-sandbox
      CODE_MAX_NUMBER: "9223372036854775807"
      CODE_MIN_NUMBER: "-9223372036854775808"
      CODE_MAX_STRING_LENGTH: "80000"
      TEMPLATE_TRANSFORM_MAX_LENGTH: "80000"
      CODE_MAX_STRING_ARRAY_LENGTH: "30"
      CODE_MAX_OBJECT_ARRAY_LENGTH: "30"
      CODE_MAX_NUMBER_ARRAY_LENGTH: "1000"
      SSRF_PROXY_HTTP_URL: "http://ssrf_proxy:3128"
      SSRF_PROXY_HTTPS_URL: "http://ssrf_proxy:3128"
      INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: "1000"
    depends_on:
      - db
      - redis
    volumes:
      - /DATA/AppData/$AppID/data/app/api/storage:/app/api/storage
    networks:
      - ssrf_proxy_network
      - dify

  worker:
    image: langgenius/dify-api:0.12.1
    container_name: dify-worker
    restart: unless-stopped
    environment:
      MODE: worker
      LOG_LEVEL: INFO
      SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
      DB_USERNAME: postgres
      DB_PASSWORD: difyai123456
      DB_HOST: db
      DB_PORT: "5432"
      DB_DATABASE: dify
      REDIS_HOST: redis
      REDIS_PORT: "6379"
      REDIS_PASSWORD: difyai123456
      REDIS_DB: "0"
      REDIS_USE_SSL: "false"
      CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
      STORAGE_TYPE: local
      STORAGE_LOCAL_PATH: storage
      VECTOR_STORE: weaviate
      WEAVIATE_ENDPOINT: http://weaviate:8080
      WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
    depends_on:
      - db
      - redis
    volumes:
      - /DATA/AppData/$AppID/data/app/api/storage:/app/api/storage
    networks:
      - ssrf_proxy_network
      - dify

  web:
    image: langgenius/dify-web:0.12.1
    container_name: dify-web
    restart: unless-stopped
    environment:
      CONSOLE_API_URL: ""
      APP_API_URL: ""
    deploy:
      resources:
        reservations:
          memory: 2048M
    networks:
      - dify

  db:
    image: postgres:15-alpine
    container_name: dify-db
    restart: unless-stopped
    environment:
      PGUSER: postgres
      POSTGRES_PASSWORD: difyai123456
      POSTGRES_DB: dify
      PGDATA: /var/lib/postgresql/data/pgdata
    command: >
      postgres -c 'max_connections=100'
               -c 'shared_buffers=128MB'
               -c 'work_mem=4MB'
               -c 'maintenance_work_mem=64MB'
               -c 'effective_cache_size=4096MB'
    volumes:
      - /DATA/AppData/$AppID/data/db/data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD", "pg_isready"]
      interval: 1s
      timeout: 3s
      retries: 30
    networks:
      - dify

  redis:
    image: redis:6-alpine
    container_name: dify-redis
    restart: unless-stopped
    environment:
      REDISCLI_AUTH: difyai123456
    volumes:
      - /DATA/AppData/$AppID/data/redis/data:/data
    command: redis-server --requirepass difyai123456
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
    networks:
      - dify

  weaviate:
    image: semitechnologies/weaviate:1.19.0
    container_name: dify-weaviate
    restart: unless-stopped
    volumes:
      - /DATA/AppData/$AppID/data/weaviate:/var/lib/weaviate
    environment:
      QUERY_DEFAULTS_LIMIT: "25"
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "false"
      PERSISTENCE_DATA_PATH: /var/lib/weaviate
      DEFAULT_VECTORIZER_MODULE: none
      CLUSTER_HOSTNAME: node1
      AUTHENTICATION_APIKEY_ENABLED: "true"
      AUTHENTICATION_APIKEY_ALLOWED_KEYS: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
      AUTHENTICATION_APIKEY_USERS: hello@dify.ai
      AUTHORIZATION_ADMINLIST_ENABLED: "true"
      AUTHORIZATION_ADMINLIST_USERS: hello@dify.ai
    networks:
      - dify

  sandbox:
    image: langgenius/dify-sandbox:0.2.10
    container_name: dify-sandbox
    restart: unless-stopped
    environment:
      API_KEY: dify-sandbox
      GIN_MODE: release
      WORKER_TIMEOUT: "15"
      ENABLE_NETWORK: "true"
      HTTP_PROXY: "http://ssrf_proxy:3128"
      HTTPS_PROXY: "http://ssrf_proxy:3128"
      SANDBOX_PORT: "8194"
    volumes:
      - /DATA/AppData/$AppID/data/sandbox/dependencies:/dependencies
    networks:
      - ssrf_proxy_network
    depends_on:
      - config

  ssrf_proxy:
    image: ubuntu/squid:latest
    container_name: dify-ssrf_proxy
    restart: unless-stopped
    environment:
      HTTP_PORT: 3128
      COREDUMP_DIR: /var/spool/squid
      REVERSE_PROXY_PORT: 8194
      SANDBOX_HOST: sandbox
      SANDBOX_PORT: 8194

    volumes:
      - /DATA/AppData/$AppID/data/ssrf_proxy:/etc/squid
    networks:
      - ssrf_proxy_network
      - dify
    depends_on:
      - config

  nginx:
    image: nginx:latest
    container_name: dify-nginx
    restart: unless-stopped
    volumes:
      - /DATA/AppData/$AppID/data/nginx:/etc/nginx
    depends_on:
      - api
      - web
      - config
    ports:
      - "3701:80"
    networks:
      - dify

networks:
  ssrf_proxy_network:
    driver: bridge
    internal: true
  dify:
    name: dify

x-casaos:
  architectures:
    - arm64
    - amd64
  main: web
  author: IceWhaleTech
  developer: LangGenius
  category: Chat
  description:
    en_us: Dify is an open-source large language model (LLM) application development platform. It combines the concepts of Backend-as-a-Service and LLMOps to enable developers to quickly build production-grade generative AI applications. Even non-technical personnel can participate in the definition and data operations of AI applications.
    en_uk: Dify is an open-source large language model (LLM) application development platform. It combines the concepts of Backend-as-a-Service and LLMOps to enable developers to quickly build production-grade generative AI applications. Even non-technical personnel can participate in the definition and data operations of AI applications.
    zh_cn: Dify 是一款开源的大语言模型(LLM) 应用开发平台。它融合了后端即服务（Backend as Service）和 LLMOps 的理念，使开发者可以快速搭建生产级的生成式 AI 应用。即使你是非技术人员，也能参与到 AI 应用的定义和数据运营过程中。
    ja_jp: Difyはオープンソースの大規模言語モデル（LLM）開発プラットフォームです。Backend as ServiceとLLMOpsの理念を融合し、開発者が迅速に生成AIアプリケーションを構築できるようにします。技術者でなくても、AIアプリケーションの定義やデータ運用に参加することができます。
  icon: https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/Dify/icon.png
  screenshot_link:
    - https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/Dify/screenshot-1.png
    - https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/Dify/screenshot-2.png
    - https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/Dify/screenshot-3.png
    - https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/Dify/screenshot-4.png
  thumbnail: https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/Dify/thumbnail.png
  tagline:
    en_us: LLM App Development Platform
  title:
    en_us: Dify
  index: /
  port_map: "3701"
