This guide deploys Chatwoot with Docker Compose, PostgreSQL, Redis, and Sidekiq worker.
It supports Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install Chatwoot with Docker
hosts: chatwoot
become: true
vars:
chatwoot_root: /opt/chatwoot
chatwoot_port: 3000
chatwoot_url: https://chatwoot.example.com
postgres_password: "change-me-now"
secret_key_base: "generate-with-rails-secret-keygen"
# Generate MFA keys with: rails db:encryption:init
encryption_primary_key: "generate-me"
encryption_deterministic_key: "generate-me"
encryption_key_derivation_salt: "generate-me"
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create Chatwoot directory
file:
path: "{{ chatwoot_root }}"
state: directory
mode: "0755"
- name: Write Chatwoot .env file
copy:
dest: "{{ chatwoot_root }}/.env"
mode: "0600"
content: |
FRONTEND_URL={{ chatwoot_url }}
SECRET_KEY_BASE={{ secret_key_base }}
POSTGRES_HOST=postgres
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD={{ postgres_password }}
POSTGRES_DB=chatwoot
REDIS_URL=redis://redis:6379
RAILS_ENV=production
NODE_ENV=production
INSTALLATION_ENV=docker
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY={{ encryption_primary_key }}
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY={{ encryption_deterministic_key }}
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT={{ encryption_key_derivation_salt }}
- name: Write Chatwoot compose file
copy:
dest: "{{ chatwoot_root }}/docker-compose.yml"
mode: "0644"
content: |
services:
postgres:
image: pgvector/pgvector:pg16
restart: unless-stopped
environment:
POSTGRES_DB: chatwoot
POSTGRES_USER: postgres
POSTGRES_PASSWORD: {{ postgres_password }}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- chatwoot_network
redis:
image: redis:alpine
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- chatwoot_network
chatwoot:
image: chatwoot/chatwoot:v4.12.0
restart: unless-stopped
depends_on:
- postgres
- redis
ports:
- "{{ chatwoot_port }}:3000"
environment:
RAILS_ENV: production
NODE_ENV: production
INSTALLATION_ENV: docker
env_file:
- {{ chatwoot_root }}/.env
volumes:
- storage_data:/app/storage
networks:
- chatwoot_network
sidekiq:
image: chatwoot/chatwoot:v4.12.0
restart: unless-stopped
depends_on:
- postgres
- redis
environment:
RAILS_ENV: production
NODE_ENV: production
INSTALLATION_ENV: docker
env_file:
- {{ chatwoot_root }}/.env
volumes:
- storage_data:/app/storage
command: bundle exec sidekiq -C config/sidekiq.yml
networks:
- chatwoot_network
volumes:
postgres_data:
redis_data:
storage_data:
networks:
chatwoot_network:
driver: bridge
- name: Prepare Chatwoot database
command: docker compose run --rm chatwoot bundle exec rails db:chatwoot_prepare
args:
chdir: "{{ chatwoot_root }}"
run_once: true
- name: Start Chatwoot stack
command: docker compose up -d
args:
chdir: "{{ chatwoot_root }}"
https://chatwoot.example.comAny questions?
Feel free to contact us. Find all contact information on our contact page.