version: "3"

services:
  chatwoot:
    image: chatwoot/chatwoot:v1.7.0 
    restart: unless-stopped
    container_name: chatwoot
    env_file: chatwoot-config.env
    environment:
      FRONTEND_URL: ${BTCPAY_PROTOCOL:-https}://${CHATWOOT_HOST}
      FORCE_SSL: "true"
      REDIS_URL: redis://redis:6379
      POSTGRES_HOST: postgres
      POSTGRES_USERNAME: postgres
      RAILS_ENV: production
      NODE_ENV: production
      RAILS_MAX_THREADS: 5
      REDIS_PASSWORD: ""
      RAILS_LOG_TO_STDOUT: "true"
      LOG_LEVEL: info
      LOG_SIZE: 500
      IOS_APP_ID: 6C953F3RX2.com.chatwoot.app
      LETSENCRYPT_HOST: ${CHATWOOT_HOST}
      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-<no value>}
      VIRTUAL_HOST: ${CHATWOOT_HOST}
      VIRTUAL_HOST_NAME: "chatwoot"
      VIRTUAL_PORT: 3000
    expose:
      - "3000"
    depends_on:
      - postgres
      - redis
    entrypoint: docker/entrypoints/rails.sh
    command: "bundle exec rails s -p 3000 -b 0.0.0.0"

  chatwoot_sidekiq:
    image: chatwoot/chatwoot:v1.7.0   
    restart: unless-stopped
    env_file: chatwoot-config.env
    environment:
      FRONTEND_URL: ${BTCPAY_PROTOCOL:-https}://${CHATWOOT_HOST}
      FORCE_SSL: "true"
      REDIS_URL: redis://redis:6379
      POSTGRES_HOST: postgres
      POSTGRES_USERNAME: postgres
      RAILS_ENV: production
      NODE_ENV: production
      RAILS_MAX_THREADS: 5
      REDIS_PASSWORD: ""
      RAILS_LOG_TO_STDOUT: "true"
      LOG_LEVEL: info
      LOG_SIZE: 500
      IOS_APP_ID: 6C953F3RX2.com.chatwoot.app
    depends_on:
      - postgres
      - redis
    command: "bundle exec sidekiq -C config/sidekiq.yml"
  redis:
    image: redis:5.0.2-alpine    
    restart: unless-stopped
    expose:
      - "6379"
    volumes:
      - "redis_datadir:/data"
  btcpayserver:
    environment:
      BTCPAY_EXTERNALSERVICES: "Chatwoot:${BTCPAY_PROTOCOL:-https}://${CHATWOOT_HOST};"

volumes:
    redis_datadir: