version: "3.7"

services:
  evolution_v2:  
    image: atendai/evolution-api:v2.2.1 ## Versão da Evolution API
    volumes:
      - evolution_instancesv2:/evolution/instances
    networks:
      - network_public
    environment:
    ## Url da Evolution API
    - SERVER_URL=https://seudominio.app.br
    ## Dados de Autenticação
    - AUTHENTICATION_TYPE=apikey
    - AUTHENTICATION_API_KEY=Sua api key ## GLOBAL API KEY
    - AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true
    ## Configurações
    - LANGUAGE=pt-BR
    - CONFIG_SESSION_PHONE_CLIENT=WhatsAPI ## Nome que aparece no celular
    - CONFIG_SESSION_PHONE_NAME=chrome    
    ## Definir versão do Whatsapp Web
    ## pegue a versão em: https://web.whatsapp.com/check-update?version=0&platform=web
    - CONFIG_SESSION_PHONE_VERSION=2.3000.1015901307
    ## Configurações do Whatsapp Business Cloud (Api Oficial)
    - WA_BUSINESS_TOKEN_WEBHOOK=evolution
    - WA_BUSINESS_URL=https://graph.facebook.com
    - WA_BUSINESS_VERSION=v20.0
    - WA_BUSINESS_LANGUAGE=pt_BR
    ## Sobre o QR-Code
    - QRCODE_LIMIT=9999999999
    - QRCODE_COLOR=#47A7F6
    ## Aivar Banco de Dados Postgres
    - DATABASE_ENABLED=true
    - DATABASE_PROVIDER=postgresql
    - DATABASE_CONNECTION_URI=postgresql://postgres:Mfcd62!!Mfcd62!!@postgres:5432/evolution
    - DATABASE_CONNECTION_CLIENT_NAME=evolution
    - DATABASE_SAVE_DATA_INSTANCE=true
    - DATABASE_SAVE_DATA_NEW_MESSAGE=true
    - DATABASE_SAVE_MESSAGE_UPDATE=true
    - DATABASE_SAVE_DATA_CONTACTS=true
    - DATABASE_SAVE_DATA_CHATS=true
    # OpenAI
    - OPENAI_ENABLED=true
    # Dify
    - DIFY_ENABLED=true
    ## Ativar Banco de dados MinIO ou S3
    - S3_ENABLED=false
    - S3_ACCESS_KEY=
    - S3_SECRET_KEY=
    - S3_BUCKET=evolution
    - S3_PORT=443
    - S3_ENDPOINT=
    - S3_USE_SSL=true    
    ## Ativar o Cache Redis
    - CACHE_REDIS_ENABLED=true
    - CACHE_REDIS_URI=redis://redis:6379/2
    - CACHE_REDIS_PREFIX_KEY=evolution
    - CACHE_REDIS_SAVE_INSTANCES=false
    - CACHE_LOCAL_ENABLED=false
    ## Configurações das instancias
    - DEL_INSTANCE=false
    - DEL_TEMP_INSTANCES=false
    ## Carregar módulo Typebot
    - TYPEBOT_ENABLED=true
    - TYPEBOT_API_VERSION=latest
    ## Carregar módulo Chatwoot
    - CHATWOOT_ENABLED=true
    - CHATWOOT_MESSAGE_READ=true
    - CHATWOOT_MESSAGE_DELETE=true
    - CHATWOOT_IMPORT_DATABASE_CONNECTION_URI=postgresql://postgres:Mfcd62!!Mfcd62!!@postgres:5432/chatwoot?sslmode=disable
    - CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE=false ## true = Importar midia | false = Não importar midia     
    ## Dados do RabbitMQ
    - RABBITMQ_ENABLED=false
    - RABBITMQ_URI=amqp://admin:admin@rabbitmq:5672/default
    - RABBITMQ_EXCHANGE_NAME=evolution
    - RABBITMQ_GLOBAL_ENABLED=false
    - RABBITMQ_EVENTS_APPLICATION_STARTUP=false
    - RABBITMQ_EVENTS_INSTANCE_CREATE=false
    - RABBITMQ_EVENTS_INSTANCE_DELETE=false
    - RABBITMQ_EVENTS_QRCODE_UPDATED=false
    - RABBITMQ_EVENTS_MESSAGES_SET=false
    - RABBITMQ_EVENTS_MESSAGES_UPSERT=true
    - RABBITMQ_EVENTS_MESSAGES_EDITED=false
    - RABBITMQ_EVENTS_MESSAGES_UPDATE=false
    - RABBITMQ_EVENTS_MESSAGES_DELETE=false
    - RABBITMQ_EVENTS_SEND_MESSAGE=false
    - RABBITMQ_EVENTS_CONTACTS_SET=false
    - RABBITMQ_EVENTS_CONTACTS_UPSERT=false
    - RABBITMQ_EVENTS_CONTACTS_UPDATE=false
    - RABBITMQ_EVENTS_PRESENCE_UPDATE=false
    - RABBITMQ_EVENTS_CHATS_SET=false
    - RABBITMQ_EVENTS_CHATS_UPSERT=false
    - RABBITMQ_EVENTS_CHATS_UPDATE=false
    - RABBITMQ_EVENTS_CHATS_DELETE=false
    - RABBITMQ_EVENTS_GROUPS_UPSERT=false
    - RABBITMQ_EVENTS_GROUP_UPDATE=false
    - RABBITMQ_EVENTS_GROUP_PARTICIPANTS_UPDATE=false
    - RABBITMQ_EVENTS_CONNECTION_UPDATE=true
    - RABBITMQ_EVENTS_CALL=false
    - RABBITMQ_EVENTS_TYPEBOT_START=false
    - RABBITMQ_EVENTS_TYPEBOT_CHANGE_STATUS=false
    ## Informações do Webhook
    - WEBHOOK_GLOBAL_ENABLED=false
    - WEBHOOK_GLOBAL_URL=
    - WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=false
    - WEBHOOK_EVENTS_APPLICATION_STARTUP=false
    - WEBHOOK_EVENTS_QRCODE_UPDATED=true
    - WEBHOOK_EVENTS_MESSAGES_SET=true
    - WEBHOOK_EVENTS_MESSAGES_UPSERT=true
    - WEBHOOK_EVENTS_MESSAGES_EDITED=true
    - WEBHOOK_EVENTS_MESSAGES_UPDATE=true
    - WEBHOOK_EVENTS_MESSAGES_DELETE=true
    - WEBHOOK_EVENTS_SEND_MESSAGE=true
    - WEBHOOK_EVENTS_CONTACTS_SET=true
    - WEBHOOK_EVENTS_CONTACTS_UPSERT=true
    - WEBHOOK_EVENTS_CONTACTS_UPDATE=true
    - WEBHOOK_EVENTS_PRESENCE_UPDATE=true
    - WEBHOOK_EVENTS_CHATS_SET=true
    - WEBHOOK_EVENTS_CHATS_UPSERT=true
    - WEBHOOK_EVENTS_CHATS_UPDATE=true
    - WEBHOOK_EVENTS_CHATS_DELETE=true
    - WEBHOOK_EVENTS_GROUPS_UPSERT=true
    - WEBHOOK_EVENTS_GROUPS_UPDATE=true
    - WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
    - WEBHOOK_EVENTS_CONNECTION_UPDATE=true
    - WEBHOOK_EVENTS_LABELS_EDIT=true
    - WEBHOOK_EVENTS_LABELS_ASSOCIATION=true
    - WEBHOOK_EVENTS_CALL=true
    - WEBHOOK_EVENTS_TYPEBOT_START=false
    - WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS=false
    - WEBHOOK_EVENTS_ERRORS=false
    - WEBHOOK_EVENTS_ERRORS_WEBHOOK=

    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
        - node.role == manager
      labels:
      - traefik.enable=1
      - traefik.http.routers.evolution_v2.rule=Host(`seudominio.app.br`) ## Url da aplicação
      - traefik.http.routers.evolution_v2.entrypoints=websecure
      - traefik.http.routers.evolution_v2.priority=1
      - traefik.http.routers.evolution_v2.tls.certresolver=letsencryptresolver
      - traefik.http.routers.evolution_v2.service=evolution_v2
      - traefik.http.services.evolution_v2.loadbalancer.server.port=8080
      - traefik.http.services.evolution_v2.loadbalancer.passHostHeader=true


volumes:
  evolution_instancesv2:
    external: true
    name: evolution_instancesv2

networks:
  network_public:
    name: network_public
    external: true