This guide uses Docker Compose to run Chatwoot with PostgreSQL, Redis, and Sidekiq worker.
For Docker installation, see Docker.
mkdir -p /opt/chatwoot
cd /opt/chatwoot
wget -O .env https://raw.githubusercontent.com/chatwoot/chatwoot/develop/.env.example
Edit the .env file with your settings:
nano .env
Required variables:
# Application
FRONTEND_URL=https://chatwoot.example.com
SECRET_KEY_BASE=generate-with-rails-secret-keygen
# Database
POSTGRES_HOST=postgres
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=change-me-now
POSTGRES_DB=chatwoot
# Redis
REDIS_URL=redis://redis:6379
# Runtime
RAILS_ENV=production
NODE_ENV=production
INSTALLATION_ENV=docker
# Active Record Encryption (REQUIRED for MFA/2FA)
# Generate with: rails db:encryption:init
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=generate-me
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=generate-me
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=generate-me
Note on Docker Tags: Chatwoot provides several Docker tags:
v4.x.x - Specific version (recommended for production)master - Stable branchdevelop - Development branch (unstable, not recommended for production)latest - May point to development buildsFor production, use a specific version tag like v4.12.0.
cat <<'YAML' > docker-compose.yml
services:
postgres:
image: pgvector/pgvector:pg16
restart: unless-stopped
environment:
POSTGRES_DB: chatwoot
POSTGRES_USER: postgres
POSTGRES_PASSWORD: change-me-now
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- chatwoot_network
# Note: PostgreSQL 16 with pgvector for AI features. Use postgres:12+ for basic deployment.
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:
- "127.0.0.1:3000:3000"
environment:
RAILS_ENV: production
NODE_ENV: production
INSTALLATION_ENV: docker
env_file:
- .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:
- .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
YAML
Initialize the database with required migrations:
docker compose run --rm chatwoot bundle exec rails db:chatwoot_prepare
docker compose up -d
# Check all services are running
docker compose ps
# Test API endpoint
curl -I http://127.0.0.1:3000/api
For production access, set up Nginx with Let’s Encrypt:
# Install Nginx
apt install nginx certbot python3-certbot-nginx
# Create Nginx config
cat <<'NGINX' > /etc/nginx/sites-available/chatwoot.example.com
server {
server_name chatwoot.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
NGINX
# Enable site
ln -s /etc/nginx/sites-available/chatwoot.example.com /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
# Get SSL certificate
certbot --nginx -d chatwoot.example.com
cd /opt/chatwoot
docker compose pull
docker compose up -d
docker compose run --rm chatwoot bundle exec rails db:chatwoot_prepare
Running containers in production? We help with:
Need help? office@linux-server-admin.com or Contact Us