Skip to main content

Docker Chatwoot Production deployment guide

Steps to deploy Chatwoot using docker-compose#

1) Install Docker on your VM

# example in ubuntu
apt-get update
apt install docker-compose

2) Download the required files

# Download the env file template
wget -O .env
# Download the Docker compose template
wget -O docker-compose.yml

3) Tweak the .env and docker-compose.yml according to your preferences. Refer to the available environment variables. You could also remove the dependant services like Postgres, Redis etc., in favor of managed services configured via environment variables.

Update POSTGRES_PASSWORD in both docker-compose.yml and .env

4) Prepare the database by running the migrations.

docker-compose run --rm rails bundle exec rails db:chatwoot_prepare

5) Get the service up and running.

docker-compose up -d

6) Your Chatwoot installation should be accessible with http://{your_ip_address}:3000

Additional Steps#

1) Have an Nginx web server acting as a reverse proxy for Chatwoot installation. So that you can access Chatwoot from 2) Run docker-compose run --rm rails bundle exec rails db:chatwoot_prepare whenever you decide to update the Chatwoot images to handle the migrations.

Configure Nginx and Let's Encrypt#

  1. Configure Nginx to serve as a frontend proxy.
sudo apt-get install nginx
cd /etc/nginx/sites-enabled
  1. Use the following Nginx config after replacing the in server_name .
server {
server_name <>;
# Point upstream to Chatwoot App Server
set $upstream;
# Nginx strips out underscore in headers by default
# Chatwoot relies on underscore in headers for API
# Make sure that the config is set to on.
underscores_in_headers on;
location /.well-known {
alias /var/www/ssl-proof/chatwoot/.well-known;
location / {
proxy_pass_header Authorization;
proxy_pass http://$upstream;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection โ€œโ€;
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
listen 80;
  1. Verify and reload your Nginx config by running the following command.
nginx -t
systemctl reload nginx
  1. Run Let's Encrypt to configure SSL certificate.
apt install certbot
apt-get install python3-certbot-nginx
mkdir -p /var/www/ssl-proof/chatwoot/.well-known
certbot --webroot -w /var/www/ssl-proof/chatwoot/ -d -i nginx
  1. Your Chatwoot installation should be accessible from the now.

Steps to build images yourself#

We publish our base images to the Docker hub. You should be able to build your Chatwoot web/worker images from these base images.


FROM chatwoot/chatwoot:latest
RUN chmod +x docker/entrypoints/
ENTRYPOINT ["docker/entrypoints/"]
CMD bundle exec bundle exec rails s -b -p 3000


FROM chatwoot/chatwoot:latest
RUN chmod +x docker/entrypoints/
ENTRYPOINT ["docker/entrypoints/"]
CMD bundle exec sidekiq -C config/sidekiq.yml

The app servers will run available on port 3000. Ensure the images connect to the same database and Redis servers. Provide the configuration for these services via environment variables.

Initial database setup#

To set up the database for the first time, you must run rails db:chatwoot_prepare. You may get errors if you try to run rails db:migrate at this point.


Update the images using the latest image from chatwoot. Run the rails db:chatwoot_prepare option after accessing the console from one of the containers running the latest image.