version: 1.0
provider:
  name: openfaas
  gateway: http://192.168.68.70:8082
functions:
  well-api:
    image: repo.eluxnetworks.net/well-api:latest
    annotations:
      com.openfaas.timeouts.read: "60s"
      com.openfaas.timeouts.write: "60s"
      com.openfaas.timeouts.exec: "60s"
    volumes:
      - /home/app/well_web_storage:/home/app/well_web_storage
    labels:
      com.openfaas.scale.min: 1
      com.openfaas.scale.max: 10
      com.openfaas.scale.factor: 20%
      com.openfaas.scale.zero: false
      # Traefik routing configuration
      traefik.enable: true
      traefik.docker.network: traefik-public
      traefik.http.routers.well-api.rule: Host(`eluxnetworks.net`) && PathPrefix(`/function/well-api`)
      traefik.http.routers.well-api.entrypoints: websecure
      traefik.http.routers.well-api.tls.certresolver: letsencrypt
      traefik.http.services.well-api.loadbalancer.server.port: 8080
      # Set a higher priority to ensure this rule takes precedence
      traefik.http.routers.well-api.priority: 100
    environment:
      read_timeout: "60s"
      write_timeout: "60s"
      exec_timeout: "60s"
      combine_output: true
      # Gunicorn-specific settings
      GUNICORN_WORKERS: "2"
      GUNICORN_THREADS: "4"

      DB_NAME: "wellnuo"
      DB_USER: "well_app"
      DB_PASSWORD: "well_app_2024"
      DB_HOST: "192.168.68.70"
      DB_PORT: "5432"
      MINIO_ACCESS_KEY: "well_pipe"
      MINIO_SECRET_KEY: "WellNuo_2024"
      MINIO_HOST: "192.168.68.70"
      MINIO_PORT: "9000"
      DAILY_MAPS_BUCKET_NAME: "daily-maps"
      JWT_SECRET: "Well_202502110501"
      MASTER_ADMIN: "robster"
      MASTER_PS: "rob2"
      OPENAI_API_KEY: "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"
      OPENAI_API_MODEL_ENGINE: "gpt-3.5-turbo"
      REDIS_PORT: "6379"
      TELNYX_API_KEY: "KEY0196087A75998434A30FA637CE4FDAFF_ZljGj9KBSAQL0zXx4Sb5eW"
      TELNYX_API_BASE_URL: "https://api.telnyx.com/v2"

    deploy:
      resources:
        limits:
          memory: 256Mi
        requests:
          memory: 128Mi
      networks:
        - func_functions
        - traefik-public
networks:
  func_functions:
    external: true
  traefik-public:
    external: true
