networks:
  vpn:
    external: true

services:
  proxy:
    ports:
      - "PORT1:80" # specify port forewarding
    #labels:
      #traefik.enable: true
      #traefik.http.routers.tiledesk.entrypoints: web,websecure
      #traefik.http.routers.tiledesk.rule: Host(`DOMAINSUBNAMEHERE`)
      #traefik.http.routers.tiledesk.tls: true
      #traefik.http.routers.tiledesk.tls.certresolver: production
      #traefik.http.routers.tiledesk.middlewares:
    healthcheck:
      disable: false #HEALTHCHECKHERE
    networks:
      vpn:
         ipv4_address: IPADDRESSHERE
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro #SOCKETHERE

  mongo:
    volumes:
      - ./tiledesk-datadb:/data/db

  dashboard:
   environment: 
      - "WIDGET_LOCATION=${EXTERNAL_BASE_URL:-http://localhost:8081}/widget/"
      - "API_BASEIMAGE_URL=${EXTERNAL_BASE_URL:-http://localhost:8081}/api/"
   ports:
      - "4500:80" #use expose if you want to block external access

  webwidget:
   image: chat21/chat21-web-widget:5.0.70
   container_name: chat21-web-widget 
   ports: 
      - "4200:80" # specify port forewarding
   environment: 
      - "MQTT_ENDPOINT=${EXTERNAL_MQTT_BASE_URL:-ws://localhost:8081}/mqws/ws"
      - "MQTT_APIENDPOINT=${EXTERNAL_BASE_URL:-http://localhost:8081}/chatapi/api"      
      - "API_URL=${EXTERNAL_BASE_URL:-http://localhost:8081}/api/"
      - "TRANSLATIONS_URL=${EXTERNAL_BASE_URL:-http://localhost:8081}/api/"
      - "API_BASEIMAGE_URL=${EXTERNAL_BASE_URL:-http://localhost:8081}/api/"

  ionic:
   image: chat21/chat21-ionic:3.0.101
   container_name: chat21-ionic
   ports:
      - "8082:80" #use expose if you want to block external access   
   environment: 
      - "MQTT_ENDPOINT=${EXTERNAL_MQTT_BASE_URL:-ws://localhost:8081}/mqws/ws"
  server:
    image: tiledesk/tiledesk-server:2.4.67
      - CHAT21_URL=http://chat21httpserver:8004
      - "EMAIL_BASEURL=${EXTERNAL_BASE_URL:-http://localhost:8081}/dashboard"
      - "WEBHOOK_ORIGIN=${EXTERNAL_BASE_URL:-http://localhost:8081}/api/"
      - "WIDGET_LOCATION=${EXTERNAL_BASE_URL:-http://localhost:8081}/widget/launch.js"
      - "WIDGET_TEST_LOCATION=${EXTERNAL_BASE_URL:-http://localhost:8081}/widget/assets/test_widget_page/index.html"
      - CACHE_REDIS_PORT=6379
    ports:
      - "3000:3000"

  chat21httpserver:  
    environment: 
      - RABBITMQ_URI=amqp://ignored:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiMjM1OTFmZS05N2FhLTRmNWQtOGVlOS0yNjQ2NzljYmM0M2YiLCJzdWIiOiIxMDAtQVBJQURNSU4iLCJzY29wZSI6WyJyYWJiaXRtcS5yZWFkOiovKi8qIiwicmFiYml0bXEud3JpdGU6Ki8qLyoiLCJyYWJiaXRtcS5jb25maWd1cmU6Ki8qLyoiXSwiY2xpZW50X2lkIjoiMTAwLUFQSUFETUlOIiwiY2lkIjoiMTAwLUFQSUFETUlOIiwiYXpwIjoiMTAwLUFQSUFETUlOIiwidXNlcl9pZCI6IjEwMC1BUElBRE1JTiIsImFwcF9pZCI6InRpbGVjaGF0IiwiaWF0IjoxNjk2NDkyMjg3LCJleHAiOjIwMDc1MzIyODcsImF1ZCI6WyJyYWJiaXRtcSIsIjEwMC1BUElBRE1JTiJdLCJraWQiOiJ0aWxlZGVzay1rZXkiLCJ0aWxlZGVza19hcGlfcm9sZXMiOiJhZG1pbiJ9.Ee-TpAPsoC7Dm7qsbUojeHud3E4OCtJZkpupu_R0Aic@rabbitmq:5672?heartbeat=60
      - PUSH_WH_NOTIFY_URL=http://localhost:8004/api/tilechat/notify
      - CONTACTS_LOOKUP_ENDPOINT=http://server:3000/users_util
    ports:
      - "8004:8004"

  chat21server:
    environment: 
      - WEBHOOK_ENDPOINTS=http://server:3000/chat21/requests,http://chat21httpserver:8004/api/tilechat/push/webhook/endpoint/WHFyAhecCMkYsvldLFWbSrJt7lAZFAmrp7O5QVMvGQsLVn9SkfT
    depends_on:
      - mongo
      - rabbitmq
      - server 

  rabbitmq:
    ports:
        - 5672:5672
        - 15672:15672
        - 1883:1883
        - 15675:15675

  redis:
    ports:
      - "6379:6379"
