add mintlify intro docs

This commit is contained in:
Tanmay Deep Sharma
2025-05-28 23:42:34 +05:30
parent b5ebc47637
commit f429db89b4
19 changed files with 10055 additions and 1 deletions
@@ -0,0 +1,416 @@
---
title: Chatwoot CTL (cwctl)
description: Command-line tool for managing Chatwoot installations with ease
sidebarTitle: Chatwoot CTL
---
# Chatwoot CTL (cwctl)
Chatwoot CTL (`cwctl`) is a command-line tool that simplifies the management of your Chatwoot installation. It provides convenient commands for common administrative tasks like upgrades, restarts, console access, and log viewing.
## Installation
### Automatic Installation
`cwctl` is automatically installed when you use the Linux installation script (v2.7.0+):
```bash
wget https://get.chatwoot.app/linux/install.sh
chmod +x install.sh
./install.sh --install
```
### Manual Installation
If you have an older installation or need to install `cwctl` separately:
```bash
# Download and install cwctl
wget https://get.chatwoot.app/linux/install.sh -O /usr/local/bin/cwctl
chmod +x /usr/local/bin/cwctl
# Verify installation
cwctl --help
```
<Note>
The manual installation requires root access to install `cwctl` to `/usr/local/bin`.
</Note>
## Available Commands
### Help and Version
```bash
# Display help information
cwctl --help
cwctl -h
# Show version information
cwctl --version
cwctl -v
```
### Installation Management
```bash
# Install Chatwoot (same as running install.sh --install)
cwctl --install
# Upgrade to the latest version
cwctl --upgrade
# Restart Chatwoot services
cwctl --restart
cwctl -r
```
### Console and Debugging
```bash
# Access Rails console
cwctl --console
cwctl -c
# View web server logs
cwctl --logs web
cwctl -l web
# View worker logs
cwctl --logs worker
cwctl -l worker
# View all logs
cwctl --logs
cwctl -l
```
### Service Management
```bash
# Check service status
cwctl --status
cwctl -s
# Stop Chatwoot services
cwctl --stop
# Start Chatwoot services
cwctl --start
```
## Detailed Command Usage
### Upgrading Chatwoot
The upgrade command handles the complete upgrade process:
```bash
cwctl --upgrade
```
This command performs the following steps:
1. Switches to the chatwoot user
2. Navigates to the Chatwoot directory
3. Pulls the latest code from the master branch
4. Updates Ruby version if needed
5. Installs/updates dependencies (bundle, pnpm)
6. Precompiles assets
7. Runs database migrations
8. Updates systemd service files
9. Restarts services
<Warning>
Always backup your database before upgrading:
```bash
# Create a backup before upgrading
sudo -u postgres pg_dump chatwoot_production > chatwoot_backup_$(date +%Y%m%d).sql
```
</Warning>
### Console Access
Access the Rails console for debugging and administration:
```bash
cwctl --console
```
This opens an interactive Ruby console where you can:
```ruby
# Check application version
Rails.application.config.version
# List all accounts
Account.all
# Find a specific user
User.find_by(email: 'admin@example.com')
# Check system statistics
Account.count
User.count
Conversation.count
# Clear cache
Rails.cache.clear
```
### Log Management
View real-time logs for troubleshooting:
```bash
# Web server logs (Rails application)
cwctl -l web
# Worker logs (Sidekiq background jobs)
cwctl -l worker
# All logs (both web and worker)
cwctl -l
```
### Service Management
Control Chatwoot services:
```bash
# Check if services are running
cwctl --status
# Restart all services (web + worker)
cwctl --restart
# Stop all services
cwctl --stop
# Start all services
cwctl --start
```
## Configuration
### Environment Variables
`cwctl` respects the same environment variables as your Chatwoot installation. Key variables include:
```bash
# Chatwoot installation directory
CHATWOOT_DIR="/home/chatwoot/chatwoot"
# Rails environment
RAILS_ENV="production"
# Database configuration
DATABASE_URL="postgresql://..."
# Redis configuration
REDIS_URL="redis://..."
```
### Custom Installation Paths
If Chatwoot is installed in a non-standard location, you can specify the path:
```bash
# Set custom Chatwoot directory
export CHATWOOT_DIR="/opt/chatwoot"
cwctl --restart
```
## Troubleshooting
### Common Issues
<Accordion title="cwctl command not found">
If `cwctl` is not found, ensure it's installed and in your PATH:
```bash
# Check if cwctl exists
which cwctl
# If not found, install it
wget https://get.chatwoot.app/linux/install.sh -O /usr/local/bin/cwctl
chmod +x /usr/local/bin/cwctl
# Add to PATH if needed
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```
</Accordion>
<Accordion title="Permission denied errors">
Ensure you have the necessary permissions:
```bash
# Run with sudo if needed
sudo cwctl --restart
# Or ensure your user is in the chatwoot group
sudo usermod -a -G chatwoot $USER
```
</Accordion>
<Accordion title="Service restart failures">
If services fail to restart, check the logs:
```bash
# Check systemd status
sudo systemctl status chatwoot.target
sudo systemctl status chatwoot-web.1.service
sudo systemctl status chatwoot-worker.1.service
# View detailed logs
sudo journalctl -u chatwoot-web.1.service -f
sudo journalctl -u chatwoot-worker.1.service -f
```
</Accordion>
### Debug Mode
For verbose output during operations:
```bash
# Enable debug mode
export CWCTL_DEBUG=1
cwctl --upgrade
```
### Manual Operations
If `cwctl` fails, you can perform operations manually:
```bash
# Manual upgrade process
sudo -i -u chatwoot
cd chatwoot
git checkout master && git pull
rvm use 3.3.3 --default
bundle install
pnpm install
RAILS_ENV=production bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rake db:migrate
exit
# Restart services manually
sudo systemctl restart chatwoot.target
```
## Best Practices
### Regular Maintenance
```bash
# Weekly upgrade check
cwctl --upgrade
# Daily log monitoring
cwctl -l | grep ERROR
# Monthly service restart
cwctl --restart
```
### Backup Before Operations
```bash
# Create backup script
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
sudo -u postgres pg_dump chatwoot_production > "/backup/chatwoot_$DATE.sql"
cwctl --upgrade
```
### Monitoring
```bash
# Check service health
cwctl --status
# Monitor logs for errors
cwctl -l | grep -E "(ERROR|FATAL|Exception)"
# Check disk space before upgrades
df -h /home/chatwoot
```
## Integration with System Tools
### Systemd Integration
`cwctl` works seamlessly with systemd:
```bash
# These commands are equivalent
cwctl --restart
sudo systemctl restart chatwoot.target
cwctl --status
sudo systemctl status chatwoot.target
```
### Cron Jobs
Automate maintenance tasks:
```bash
# Add to crontab
# Weekly upgrade (Sundays at 2 AM)
0 2 * * 0 /usr/local/bin/cwctl --upgrade
# Daily restart (to clear memory leaks)
0 3 * * * /usr/local/bin/cwctl --restart
```
### Monitoring Scripts
```bash
#!/bin/bash
# Health check script
if ! cwctl --status > /dev/null 2>&1; then
echo "Chatwoot services are down, attempting restart..."
cwctl --restart
# Send alert notification
fi
```
## Advanced Usage
### Custom Commands
You can extend `cwctl` functionality by creating wrapper scripts:
```bash
#!/bin/bash
# custom-cwctl.sh - Extended cwctl with additional features
case "$1" in
--backup)
echo "Creating backup..."
sudo -u postgres pg_dump chatwoot_production > "backup_$(date +%Y%m%d).sql"
;;
--health-check)
echo "Performing health check..."
curl -f http://localhost:3000/api || echo "Health check failed"
;;
*)
cwctl "$@"
;;
esac
```
### Environment-Specific Operations
```bash
# Development environment
RAILS_ENV=development cwctl --console
# Staging environment
RAILS_ENV=staging cwctl --restart
```
---
`cwctl` simplifies Chatwoot administration by providing a unified interface for common tasks. Use it regularly to maintain your installation and troubleshoot issues efficiently.
@@ -0,0 +1,572 @@
---
title: Docker Deployment Guide
description: Complete guide to deploy Chatwoot using Docker containers for production environments.
sidebarTitle: Docker
---
Docker provides a consistent, portable way to deploy Chatwoot across different environments. This guide covers production deployment using Docker Compose with best practices for security, performance, and maintenance.
## Prerequisites
Before starting, ensure you have:
- Docker 20.10+ installed
- Docker Compose 2.0+ installed
- At least 4GB RAM and 2 CPU cores
- Domain name with DNS configured (recommended)
- Basic understanding of Docker concepts
### Version Check
Verify your Docker installation:
```bash
$ docker --version
Docker version 25.0.4, build 1a576c5
$ docker compose version
Docker Compose version v2.24.7
```
<Note>
Container names use dashes instead of underscores by default with newer Docker Compose versions. If using an older version, replace `-` with `_` and use `docker-compose` instead of `docker compose`.
</Note>
## Quick Start
### 1. Install Docker
**Ubuntu/Debian:**
```bash
# Update package index
apt-get update && apt-get upgrade -y
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Install Docker Compose plugin
apt install docker-compose-plugin
# Add user to docker group (optional)
sudo usermod -aG docker $USER
```
**CentOS/RHEL:**
```bash
# Install Docker
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Start Docker service
sudo systemctl start docker
sudo systemctl enable docker
```
### 2. Download Configuration Files
```bash
# Create project directory
mkdir chatwoot && cd chatwoot
# Download environment template
wget -O .env https://raw.githubusercontent.com/chatwoot/chatwoot/develop/.env.example
# Download Docker Compose configuration
wget -O docker-compose.yaml https://raw.githubusercontent.com/chatwoot/chatwoot/develop/docker-compose.production.yaml
```
### 3. Configure Environment
Edit the `.env` file with your settings:
```bash
nano .env
```
**Essential configurations:**
```env
# Database Configuration
POSTGRES_PASSWORD=your_secure_postgres_password
REDIS_PASSWORD=your_secure_redis_password
# Application Configuration
SECRET_KEY_BASE=your_secret_key_base_64_chars_long
FRONTEND_URL=https://your-domain.com
# Email Configuration (required for notifications)
MAILER_SENDER_EMAIL=noreply@your-domain.com
SMTP_ADDRESS=smtp.your-provider.com
SMTP_PORT=587
SMTP_USERNAME=your-smtp-username
SMTP_PASSWORD=your-smtp-password
SMTP_AUTHENTICATION=plain
SMTP_ENABLE_STARTTLS_AUTO=true
# File Storage (optional - defaults to local)
ACTIVE_STORAGE_SERVICE=local
# For S3: ACTIVE_STORAGE_SERVICE=amazon
# AWS_ACCESS_KEY_ID=your_access_key
# AWS_SECRET_ACCESS_KEY=your_secret_key
# AWS_REGION=us-east-1
# AWS_BUCKET=your-bucket-name
```
### 4. Update Docker Compose
Edit `docker-compose.yaml` to match your `.env` passwords:
```yaml
services:
postgres:
environment:
- POSTGRES_PASSWORD=your_secure_postgres_password # Match .env
redis:
command: ["sh", "-c", "redis-server --requirepass your_secure_redis_password"]
```
### 5. Initialize Database
```bash
# Prepare the database
docker compose run --rm rails bundle exec rails db:chatwoot_prepare
```
### 6. Start Services
```bash
# Start all services in background
docker compose up -d
# Check service status
docker compose ps
```
### 7. Verify Installation
```bash
# Check if Chatwoot is responding
curl -I localhost:3000/api
# Should return: HTTP/1.1 200 OK
```
## Production Configuration
### Docker Compose Setup
Here's a complete production-ready `docker-compose.yaml`:
```yaml
version: '3.8'
services:
base: &base
image: chatwoot/chatwoot:latest
env_file: .env
volumes:
- ./data/storage:/app/storage
depends_on:
- postgres
- redis
rails:
<<: *base
container_name: chatwoot-rails
command: ["sh", "-c", "bundle exec rails s -b 0.0.0.0 -p 3000"]
ports:
- "127.0.0.1:3000:3000"
environment:
- NODE_ENV=production
- RAILS_ENV=production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api"]
interval: 30s
timeout: 10s
retries: 3
sidekiq:
<<: *base
container_name: chatwoot-sidekiq
command: ["sh", "-c", "bundle exec sidekiq -C config/sidekiq.yml"]
restart: unless-stopped
healthcheck:
test: ["CMD", "pgrep", "-f", "sidekiq"]
interval: 30s
timeout: 10s
retries: 3
postgres:
image: postgres:14-alpine
container_name: chatwoot-postgres
restart: unless-stopped
ports:
- "127.0.0.1:5432:5432"
volumes:
- ./data/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_DB=chatwoot
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=your_secure_postgres_password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 30s
timeout: 10s
retries: 3
redis:
image: redis:7-alpine
container_name: chatwoot-redis
restart: unless-stopped
command: ["sh", "-c", "redis-server --requirepass your_secure_redis_password"]
ports:
- "127.0.0.1:6379:6379"
volumes:
- ./data/redis:/data
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 30s
timeout: 10s
retries: 3
volumes:
postgres_data:
redis_data:
storage_data:
```
### Nginx Reverse Proxy
Create `/etc/nginx/sites-available/chatwoot.conf`:
```nginx
server {
server_name your-domain.com;
# Point upstream to Chatwoot App Server
set $upstream 127.0.0.1:3000;
# Nginx strips out underscore in headers by default
# Chatwoot relies on underscore in headers for API
underscores_in_headers on;
# Increase client max body size for file uploads
client_max_body_size 50M;
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;
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_buffering off;
proxy_read_timeout 36000s;
proxy_redirect off;
}
listen 80;
}
```
Enable the site and configure SSL:
```bash
# Enable site
sudo ln -s /etc/nginx/sites-available/chatwoot.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# Install Certbot and get SSL certificate
sudo apt install certbot python3-certbot-nginx
sudo mkdir -p /var/www/ssl-proof/chatwoot/.well-known
sudo certbot --webroot -w /var/www/ssl-proof/chatwoot/ -d your-domain.com -i nginx
```
## Advanced Configuration
### Environment Variables
Key environment variables for production:
```env
# Application
RAILS_ENV=production
NODE_ENV=production
SECRET_KEY_BASE=generate_64_character_secret
FRONTEND_URL=https://your-domain.com
# Database
DATABASE_URL=postgresql://postgres:password@postgres:5432/chatwoot
REDIS_URL=redis://redis:6379/0
REDIS_PASSWORD=your_redis_password
# Email
MAILER_SENDER_EMAIL=noreply@your-domain.com
SMTP_ADDRESS=smtp.your-provider.com
SMTP_PORT=587
SMTP_USERNAME=your_username
SMTP_PASSWORD=your_password
SMTP_AUTHENTICATION=plain
SMTP_ENABLE_STARTTLS_AUTO=true
# File Storage
ACTIVE_STORAGE_SERVICE=amazon
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
AWS_BUCKET=your-bucket-name
# Security
FORCE_SSL=true
RAILS_LOG_TO_STDOUT=true
# Performance
RAILS_MAX_THREADS=5
WEB_CONCURRENCY=2
```
### Resource Limits
Add resource limits to your `docker-compose.yaml`:
```yaml
services:
rails:
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '1.0'
memory: 1G
sidekiq:
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
postgres:
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
redis:
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
```
### Logging Configuration
Configure centralized logging:
```yaml
services:
rails:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
sidekiq:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
```
## Maintenance Operations
### Upgrading Chatwoot
```bash
# Pull latest images
docker compose pull
# Stop services
docker compose down
# Start with new images
docker compose up -d
# Run database migrations
docker compose run --rm rails bundle exec rails db:chatwoot_prepare
```
### Backup and Restore
**Database Backup:**
```bash
# Create backup
docker compose exec postgres pg_dump -U postgres chatwoot > backup_$(date +%Y%m%d_%H%M%S).sql
# Restore backup
docker compose exec -T postgres psql -U postgres chatwoot < backup_file.sql
```
**File Storage Backup:**
```bash
# Backup storage directory
tar -czf storage_backup_$(date +%Y%m%d_%H%M%S).tar.gz ./data/storage/
```
### Monitoring and Logs
**View logs:**
```bash
# All services
docker compose logs -f
# Specific service
docker compose logs -f rails
docker compose logs -f sidekiq
# Last 100 lines
docker compose logs --tail=100 rails
```
**Monitor resources:**
```bash
# Container stats
docker stats
# Service health
docker compose ps
```
### Rails Console Access
```bash
# Access Rails console
docker compose exec rails bundle exec rails console
# Run one-off commands
docker compose run --rm rails bundle exec rails runner "puts User.count"
```
## Troubleshooting
### Common Issues
**1. Permission Issues:**
```bash
# Fix file permissions
sudo chown -R 1000:1000 ./data/
```
**2. Database Connection Issues:**
```bash
# Check database connectivity
docker compose exec rails bundle exec rails db:version
```
**3. Memory Issues:**
```bash
# Check memory usage
docker stats --no-stream
```
**4. SSL Certificate Issues:**
```bash
# Renew certificates
sudo certbot renew --dry-run
```
### Performance Optimization
**1. Database Optimization:**
```sql
-- Connect to database
docker compose exec postgres psql -U postgres chatwoot
-- Check slow queries
SELECT query, mean_time, calls
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;
```
**2. Redis Optimization:**
```bash
# Check Redis memory usage
docker compose exec redis redis-cli info memory
```
### Security Hardening
**1. Network Security:**
```yaml
# Add to docker-compose.yaml
networks:
chatwoot:
driver: bridge
internal: true
services:
rails:
networks:
- chatwoot
- default # Only rails needs external access
```
**2. Secrets Management:**
```bash
# Use Docker secrets for sensitive data
echo "your_secret_password" | docker secret create postgres_password -
```
## Community Edition vs Enterprise
This guide covers Chatwoot Community Edition (CE). For Enterprise features:
**CE Docker Tags:**
- `chatwoot/chatwoot:latest-ce` (latest CE)
- `chatwoot/chatwoot:v2.3.2-ce` (specific version CE)
**Enterprise Features:**
- Advanced reporting and analytics
- SAML SSO integration
- Advanced automation rules
- Priority support
---
<Warning>
Always test upgrades in a staging environment before applying to production. Keep regular backups of your database and file storage.
</Warning>
<Note>
For high-availability deployments, consider using Docker Swarm or Kubernetes instead of Docker Compose.
</Note>
@@ -0,0 +1,537 @@
---
title: Kubernetes Deployment
description: Deploy Chatwoot on Kubernetes using Helm charts for scalable, production-ready installations
sidebarTitle: Kubernetes
---
# Kubernetes Deployment Guide
Deploy Chatwoot on Kubernetes using our official Helm charts for a scalable, production-ready installation.
## Prerequisites
Before deploying Chatwoot on Kubernetes, ensure you have:
- **Kubernetes cluster** (v1.19+) with sufficient resources
- **Helm 3.x** installed and configured
- **kubectl** configured to access your cluster
- **Ingress controller** (nginx, traefik, etc.) for external access
- **Cert-manager** (optional, for automatic SSL certificates)
### Minimum Resource Requirements
- **CPU**: 2 cores minimum (4+ cores recommended)
- **Memory**: 4GB RAM minimum (8GB+ recommended)
- **Storage**: 20GB persistent storage for PostgreSQL
- **Nodes**: 3+ nodes for high availability
## Quick Start
### 1. Add Chatwoot Helm Repository
```bash
helm repo add chatwoot https://chatwoot.github.io/charts
helm repo update
```
### 2. Create Namespace
```bash
kubectl create namespace chatwoot
```
### 3. Install with Default Values
```bash
helm install chatwoot chatwoot/chatwoot \
--namespace chatwoot \
--set ingress.enabled=true \
--set ingress.hosts[0].host=chatwoot.yourdomain.com \
--set ingress.hosts[0].paths[0].path=/ \
--set ingress.hosts[0].paths[0].pathType=Prefix
```
## Production Configuration
### Custom Values File
Create a `values.yaml` file for production deployment:
```yaml
# values.yaml
replicaCount: 3
image:
repository: chatwoot/chatwoot
tag: "latest"
pullPolicy: IfNotPresent
env:
RAILS_ENV: production
NODE_ENV: production
FRONTEND_URL: "https://chatwoot.yourdomain.com"
FORCE_SSL: "true"
# Database Configuration
postgresql:
enabled: true
auth:
postgresPassword: "your-secure-password"
database: "chatwoot_production"
primary:
persistence:
enabled: true
size: 50Gi
storageClass: "fast-ssd"
metrics:
enabled: true
# Redis Configuration
redis:
enabled: true
auth:
enabled: true
password: "your-redis-password"
master:
persistence:
enabled: true
size: 10Gi
metrics:
enabled: true
# Ingress Configuration
ingress:
enabled: true
className: "nginx"
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
hosts:
- host: chatwoot.yourdomain.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: chatwoot-tls
hosts:
- chatwoot.yourdomain.com
# Resource Limits
resources:
limits:
cpu: 2000m
memory: 4Gi
requests:
cpu: 1000m
memory: 2Gi
# Horizontal Pod Autoscaler
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
# Storage Configuration
persistence:
enabled: true
storageClass: "fast-ssd"
size: 20Gi
# Service Configuration
service:
type: ClusterIP
port: 3000
# Worker Configuration
worker:
enabled: true
replicaCount: 2
resources:
limits:
cpu: 1000m
memory: 2Gi
requests:
cpu: 500m
memory: 1Gi
# Monitoring
serviceMonitor:
enabled: true
namespace: monitoring
```
### Deploy with Custom Configuration
```bash
helm install chatwoot chatwoot/chatwoot \
--namespace chatwoot \
--values values.yaml
```
## External Dependencies
### Using External PostgreSQL
```yaml
postgresql:
enabled: false
env:
DATABASE_URL: "postgresql://username:password@postgres-host:5432/chatwoot_production"
```
### Using External Redis
```yaml
redis:
enabled: false
env:
REDIS_URL: "redis://redis-host:6379/0"
```
### Using Cloud Storage
```yaml
env:
# AWS S3
ACTIVE_STORAGE_SERVICE: "amazon"
S3_BUCKET_NAME: "your-chatwoot-bucket"
AWS_ACCESS_KEY_ID: "your-access-key"
AWS_SECRET_ACCESS_KEY: "your-secret-key"
AWS_REGION: "us-east-1"
# Google Cloud Storage
# ACTIVE_STORAGE_SERVICE: "google"
# GCS_PROJECT: "your-project"
# GCS_BUCKET: "your-bucket"
```
## High Availability Setup
### Multi-Zone Deployment
```yaml
# Spread pods across availability zones
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- chatwoot
topologyKey: topology.kubernetes.io/zone
# Node selection
nodeSelector:
node-type: "application"
# Tolerations for dedicated nodes
tolerations:
- key: "dedicated"
operator: "Equal"
value: "chatwoot"
effect: "NoSchedule"
```
### Database High Availability
```yaml
postgresql:
enabled: true
architecture: replication
auth:
replicationPassword: "replication-password"
primary:
persistence:
enabled: true
size: 100Gi
readReplicas:
replicaCount: 2
persistence:
enabled: true
size: 100Gi
```
## Security Configuration
### Network Policies
```yaml
# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: chatwoot-network-policy
namespace: chatwoot
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: chatwoot
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: ingress-nginx
ports:
- protocol: TCP
port: 3000
egress:
- to:
- podSelector:
matchLabels:
app.kubernetes.io/name: postgresql
ports:
- protocol: TCP
port: 5432
- to:
- podSelector:
matchLabels:
app.kubernetes.io/name: redis
ports:
- protocol: TCP
port: 6379
```
### Pod Security Standards
```yaml
securityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
seccompProfile:
type: RuntimeDefault
containerSecurityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1001
capabilities:
drop:
- ALL
```
## Monitoring and Observability
### Prometheus Monitoring
```yaml
serviceMonitor:
enabled: true
labels:
app: chatwoot
interval: 30s
scrapeTimeout: 10s
path: /metrics
# Custom metrics
env:
PROMETHEUS_EXPORTER: "true"
PROMETHEUS_EXPORTER_PORT: "9394"
```
### Logging Configuration
```yaml
# Structured logging
env:
LOG_LEVEL: "info"
LOG_FORMAT: "json"
# Log aggregation with Fluentd/Fluent Bit
annotations:
fluentbit.io/parser: "json"
fluentbit.io/exclude: "false"
```
### Health Checks
```yaml
livenessProbe:
httpGet:
path: /api
port: 3000
initialDelaySeconds: 60
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /api
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
```
## Backup and Disaster Recovery
### Database Backup
```yaml
# CronJob for database backup
apiVersion: batch/v1
kind: CronJob
metadata:
name: chatwoot-db-backup
namespace: chatwoot
spec:
schedule: "0 2 * * *" # Daily at 2 AM
jobTemplate:
spec:
template:
spec:
containers:
- name: postgres-backup
image: postgres:15
command:
- /bin/bash
- -c
- |
pg_dump $DATABASE_URL | gzip > /backup/chatwoot-$(date +%Y%m%d-%H%M%S).sql.gz
# Upload to S3 or other storage
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: chatwoot-secrets
key: database-url
volumeMounts:
- name: backup-storage
mountPath: /backup
volumes:
- name: backup-storage
persistentVolumeClaim:
claimName: backup-pvc
restartPolicy: OnFailure
```
## Upgrading Chatwoot
### Rolling Update
```bash
# Update to latest version
helm upgrade chatwoot chatwoot/chatwoot \
--namespace chatwoot \
--values values.yaml
# Update to specific version
helm upgrade chatwoot chatwoot/chatwoot \
--namespace chatwoot \
--values values.yaml \
--set image.tag="v2.15.0"
```
### Database Migration
```bash
# Run migrations after upgrade
kubectl exec -it deployment/chatwoot -n chatwoot -- \
bundle exec rails db:migrate RAILS_ENV=production
```
## Troubleshooting
### Common Issues
<Tip>
**Pod Startup Issues**: Check resource limits and node capacity
```bash
kubectl describe pod <pod-name> -n chatwoot
kubectl top nodes
```
</Tip>
<Warning>
**Database Connection Issues**: Verify database credentials and network policies
```bash
kubectl logs deployment/chatwoot -n chatwoot
kubectl exec -it deployment/chatwoot -n chatwoot -- nc -zv postgres-host 5432
```
</Warning>
### Debug Commands
```bash
# Check pod status
kubectl get pods -n chatwoot
# View logs
kubectl logs -f deployment/chatwoot -n chatwoot
# Access pod shell
kubectl exec -it deployment/chatwoot -n chatwoot -- /bin/bash
# Check service endpoints
kubectl get endpoints -n chatwoot
# Describe ingress
kubectl describe ingress chatwoot -n chatwoot
```
### Performance Tuning
```yaml
# Optimize for high traffic
env:
RAILS_MAX_THREADS: "20"
WEB_CONCURRENCY: "4"
SIDEKIQ_CONCURRENCY: "25"
resources:
limits:
cpu: 4000m
memory: 8Gi
requests:
cpu: 2000m
memory: 4Gi
# Database connection pooling
env:
DATABASE_POOL_SIZE: "25"
```
## Best Practices
### Resource Management
- Set appropriate resource requests and limits
- Use horizontal pod autoscaling for dynamic scaling
- Monitor resource usage and adjust as needed
### Security
- Use network policies to restrict traffic
- Enable pod security standards
- Regularly update container images
- Use secrets for sensitive configuration
### Monitoring
- Enable Prometheus metrics collection
- Set up alerting for critical metrics
- Monitor application and infrastructure health
- Use distributed tracing for complex issues
### Backup
- Implement automated database backups
- Test backup restoration procedures
- Store backups in multiple locations
- Document recovery procedures
---
This Kubernetes deployment guide provides a solid foundation for running Chatwoot in production. Customize the configuration based on your specific requirements and infrastructure setup.
@@ -0,0 +1,675 @@
---
title: Linux VM Deployment Guide
description: Complete guide to deploy Chatwoot on Linux virtual machines using the automated installation script.
sidebarTitle: Linux VM
---
This guide covers deploying Chatwoot on Linux virtual machines using our automated installation script. This method is ideal for traditional server environments and provides full control over the installation process.
## Prerequisites
Before starting, ensure you have:
- Ubuntu 20.04 LTS or later (recommended)
- At least 4GB RAM and 2 CPU cores
- 50GB+ available disk space
- Root or sudo access
- Domain name with DNS configured (optional but recommended)
- SMTP server for email notifications
### Supported Operating Systems
| OS | Version | Status |
|---|---|---|
| **Ubuntu** | 20.04 LTS, 22.04 LTS, 24.04 LTS | ✅ Recommended |
| **Debian** | 10, 11, 12 | ✅ Supported |
| **CentOS** | 8, 9 | ✅ Supported |
| **RHEL** | 8, 9 | ✅ Supported |
| **Amazon Linux** | 2 | ✅ Supported |
## Quick Installation
### 1. Download Installation Script
```bash
# Download the installation script
wget https://get.chatwoot.app/linux/install.sh
# Make it executable
chmod +x install.sh
```
### 2. Run Installation
```bash
# Run the installation script
./install.sh --install
```
The script will:
- Install all required dependencies
- Set up PostgreSQL and Redis
- Install Ruby, Node.js, and other runtime dependencies
- Clone and configure Chatwoot
- Set up systemd services
- Configure Nginx (if domain is provided)
- Set up SSL with Let's Encrypt (if domain is provided)
### 3. Domain Configuration (Optional)
If you have a domain name:
1. **Create DNS A Record**: Point your domain to your server's IP address
2. **During installation**: Enter `yes` when prompted about domain setup
3. **Enter your domain**: The script will configure Nginx and SSL automatically
### 4. Access Your Installation
- **With domain**: `https://your-domain.com`
- **Without domain**: `http://your-server-ip:3000`
**Default login credentials:**
```
URL: https://your-domain.com
Email: john@acme.inc
Password: Password1!
```
## Manual Installation
For more control over the installation process, you can install manually:
### 1. System Preparation
```bash
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install essential packages
sudo apt install -y curl wget gnupg2 software-properties-common apt-transport-https ca-certificates lsb-release
```
### 2. Install Dependencies
**PostgreSQL:**
```bash
# Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib
# Start and enable PostgreSQL
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database and user
sudo -u postgres psql << EOF
CREATE DATABASE chatwoot;
CREATE USER chatwoot WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE chatwoot TO chatwoot;
ALTER USER chatwoot CREATEDB;
\q
EOF
```
**Redis:**
```bash
# Install Redis
sudo apt install -y redis-server
# Configure Redis
sudo sed -i 's/^# requirepass foobared/requirepass your_redis_password/' /etc/redis/redis.conf
# Start and enable Redis
sudo systemctl start redis-server
sudo systemctl enable redis-server
```
**Ruby (using RVM):**
```bash
# Install RVM
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
# Install Ruby
rvm install 3.3.3
rvm use 3.3.3 --default
```
**Node.js:**
```bash
# Install Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install pnpm
npm install -g pnpm
```
**Additional Dependencies:**
```bash
# Install build tools and libraries
sudo apt install -y git build-essential libssl-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev libyaml-dev libsqlite3-dev libgdbm-compat-dev libncurses5-dev libreadline6-dev
# Install ImageMagick for image processing
sudo apt install -y imagemagick libmagickwand-dev
# Install FFmpeg for media processing
sudo apt install -y ffmpeg
```
### 3. Install Chatwoot
```bash
# Create chatwoot user
sudo adduser --disabled-login --gecos "" chatwoot
# Switch to chatwoot user
sudo -i -u chatwoot
# Clone Chatwoot repository
git clone https://github.com/chatwoot/chatwoot.git
cd chatwoot
# Checkout latest stable version
git checkout master
# Install Ruby dependencies
bundle install
# Install Node.js dependencies
pnpm install
# Copy environment file
cp .env.example .env
```
### 4. Configure Environment
Edit the `.env` file:
```bash
nano .env
```
**Essential configurations:**
```env
# Database Configuration
DATABASE_URL=postgresql://chatwoot:your_secure_password@localhost:5432/chatwoot
# Redis Configuration
REDIS_URL=redis://localhost:6379/0
REDIS_PASSWORD=your_redis_password
# Application Configuration
SECRET_KEY_BASE=generate_a_64_character_secret_key
FRONTEND_URL=https://your-domain.com
# Email Configuration
MAILER_SENDER_EMAIL=noreply@your-domain.com
SMTP_ADDRESS=smtp.your-provider.com
SMTP_PORT=587
SMTP_USERNAME=your-smtp-username
SMTP_PASSWORD=your-smtp-password
SMTP_AUTHENTICATION=plain
SMTP_ENABLE_STARTTLS_AUTO=true
# File Storage (optional)
ACTIVE_STORAGE_SERVICE=local
# For S3: ACTIVE_STORAGE_SERVICE=amazon
# AWS_ACCESS_KEY_ID=your_access_key
# AWS_SECRET_ACCESS_KEY=your_secret_key
# AWS_REGION=us-east-1
# AWS_BUCKET=your-bucket-name
# Security
FORCE_SSL=true
RAILS_ENV=production
NODE_ENV=production
```
### 5. Setup Database
```bash
# Prepare the database
RAILS_ENV=production bundle exec rails db:chatwoot_prepare
# Precompile assets
RAILS_ENV=production bundle exec rails assets:precompile
```
### 6. Configure Systemd Services
Create systemd service files:
**Web Service (`/etc/systemd/system/chatwoot-web.1.service`):**
```ini
[Unit]
Description=Chatwoot web server
After=network.target
[Service]
Type=simple
User=chatwoot
WorkingDirectory=/home/chatwoot/chatwoot
Environment=RAILS_ENV=production
Environment=BUNDLE_GEMFILE=/home/chatwoot/chatwoot/Gemfile
ExecStart=/home/chatwoot/.rvm/bin/rvm default do bundle exec rails server -b 0.0.0.0 -p 3000 -e production
Restart=always
RestartSec=1
[Install]
WantedBy=multi-user.target
```
**Worker Service (`/etc/systemd/system/chatwoot-worker.1.service`):**
```ini
[Unit]
Description=Chatwoot sidekiq worker
After=network.target
[Service]
Type=simple
User=chatwoot
WorkingDirectory=/home/chatwoot/chatwoot
Environment=RAILS_ENV=production
Environment=BUNDLE_GEMFILE=/home/chatwoot/chatwoot/Gemfile
ExecStart=/home/chatwoot/.rvm/bin/rvm default do bundle exec sidekiq -C config/sidekiq.yml
Restart=always
RestartSec=1
[Install]
WantedBy=multi-user.target
```
**Target Service (`/etc/systemd/system/chatwoot.target`):**
```ini
[Unit]
Description=Chatwoot services
Wants=chatwoot-web.1.service chatwoot-worker.1.service
[Install]
WantedBy=multi-user.target
```
Enable and start services:
```bash
# Reload systemd
sudo systemctl daemon-reload
# Enable and start Chatwoot services
sudo systemctl enable chatwoot.target
sudo systemctl start chatwoot.target
# Check status
sudo systemctl status chatwoot.target
```
### 7. Configure Nginx
Install and configure Nginx:
```bash
# Install Nginx
sudo apt install -y nginx
# Create Nginx configuration
sudo nano /etc/nginx/sites-available/chatwoot
```
**Nginx configuration:**
```nginx
server {
server_name your-domain.com;
# Point upstream to Chatwoot App Server
set $upstream 127.0.0.1:3000;
# Nginx strips out underscore in headers by default
# Chatwoot relies on underscore in headers for API
underscores_in_headers on;
# Increase client max body size for file uploads
client_max_body_size 50M;
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;
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_buffering off;
proxy_read_timeout 36000s;
proxy_redirect off;
}
listen 80;
}
```
Enable the site:
```bash
# Enable site
sudo ln -s /etc/nginx/sites-available/chatwoot /etc/nginx/sites-enabled/
# Test configuration
sudo nginx -t
# Restart Nginx
sudo systemctl restart nginx
```
### 8. Setup SSL with Let's Encrypt
```bash
# Install Certbot
sudo apt install -y certbot python3-certbot-nginx
# Create directory for SSL verification
sudo mkdir -p /var/www/ssl-proof/chatwoot/.well-known
# Get SSL certificate
sudo certbot --webroot -w /var/www/ssl-proof/chatwoot/ -d your-domain.com -i nginx
# Test automatic renewal
sudo certbot renew --dry-run
```
## Chatwoot CLI (cwctl)
Starting with Chatwoot v2.7.0, the installation includes the Chatwoot CLI for easier management:
### Installation
If you don't have `cwctl` installed:
```bash
# Download and install cwctl
sudo wget https://get.chatwoot.app/linux/install.sh -O /usr/local/bin/cwctl
sudo chmod +x /usr/local/bin/cwctl
# Verify installation
cwctl --help
```
### Usage
```bash
# Restart Chatwoot services
cwctl -r
# Upgrade Chatwoot
cwctl --upgrade
# Access Rails console
cwctl -c
# View logs
cwctl -l web # Web server logs
cwctl -l worker # Worker logs
# Get help
cwctl --help
```
## Maintenance Operations
### Upgrading Chatwoot
**Using cwctl (recommended):**
```bash
cwctl --upgrade
```
**Manual upgrade:**
```bash
# Switch to chatwoot user
sudo -i -u chatwoot
cd chatwoot
# Pull latest changes
git checkout master && git pull
# Update Ruby version if needed
rvm install "ruby-3.3.3"
rvm use 3.3.3 --default
# Update dependencies
bundle install
pnpm install
# Precompile assets
RAILS_ENV=production bundle exec rails assets:precompile
# Run database migrations
RAILS_ENV=production bundle exec rails db:migrate
# Exit to root user
exit
# Update systemd service files
sudo cp /home/chatwoot/chatwoot/deployment/chatwoot-web.1.service /etc/systemd/system/
sudo cp /home/chatwoot/chatwoot/deployment/chatwoot-worker.1.service /etc/systemd/system/
sudo cp /home/chatwoot/chatwoot/deployment/chatwoot.target /etc/systemd/system/
# Reload and restart services
sudo systemctl daemon-reload
sudo systemctl restart chatwoot.target
```
### Backup and Restore
**Database Backup:**
```bash
# Create backup
sudo -u postgres pg_dump chatwoot > chatwoot_backup_$(date +%Y%m%d_%H%M%S).sql
# Restore backup
sudo -u postgres psql chatwoot < chatwoot_backup_file.sql
```
**File Storage Backup:**
```bash
# Backup storage directory
sudo tar -czf chatwoot_storage_$(date +%Y%m%d_%H%M%S).tar.gz /home/chatwoot/chatwoot/storage/
```
**Complete System Backup:**
```bash
# Create backup script
cat > /home/chatwoot/backup.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/backup/chatwoot/$(date +%Y%m%d_%H%M%S)"
mkdir -p $BACKUP_DIR
# Database backup
sudo -u postgres pg_dump chatwoot > $BACKUP_DIR/database.sql
# Application files
tar -czf $BACKUP_DIR/application.tar.gz /home/chatwoot/chatwoot/
# Storage files
tar -czf $BACKUP_DIR/storage.tar.gz /home/chatwoot/chatwoot/storage/
# Environment file
cp /home/chatwoot/chatwoot/.env $BACKUP_DIR/
echo "Backup completed: $BACKUP_DIR"
EOF
chmod +x /home/chatwoot/backup.sh
```
### Monitoring and Logs
**View logs:**
```bash
# Web server logs
sudo journalctl -u chatwoot-web.1.service -f
# Worker logs
sudo journalctl -u chatwoot-worker.1.service -f
# Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
# PostgreSQL logs
sudo tail -f /var/log/postgresql/postgresql-*.log
```
**System monitoring:**
```bash
# Check service status
sudo systemctl status chatwoot.target
# Check resource usage
htop
df -h
free -h
# Check database connections
sudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;"
```
### Rails Console Access
```bash
# Using cwctl
cwctl -c
# Manual access
sudo -i -u chatwoot
cd chatwoot
RAILS_ENV=production bundle exec rails console
```
## Troubleshooting
### Common Issues
**1. Asset Precompilation Fails:**
```bash
# Clear and rebuild assets
sudo -i -u chatwoot
cd chatwoot
RAILS_ENV=production bundle exec rails assets:clean assets:clobber assets:precompile
```
**2. Database Connection Issues:**
```bash
# Check PostgreSQL status
sudo systemctl status postgresql
# Test database connection
sudo -u postgres psql -c "SELECT version();"
# Check database configuration
sudo -i -u chatwoot
cd chatwoot
RAILS_ENV=production bundle exec rails db:version
```
**3. Permission Issues:**
```bash
# Fix file permissions
sudo chown -R chatwoot:chatwoot /home/chatwoot/chatwoot/
```
**4. Service Won't Start:**
```bash
# Check service logs
sudo journalctl -u chatwoot-web.1.service --no-pager
sudo journalctl -u chatwoot-worker.1.service --no-pager
# Check configuration
sudo systemctl status chatwoot.target
```
### Performance Optimization
**1. Database Optimization:**
```sql
-- Connect to database
sudo -u postgres psql chatwoot
-- Check database size
SELECT pg_size_pretty(pg_database_size('chatwoot'));
-- Check slow queries (if pg_stat_statements is enabled)
SELECT query, mean_time, calls
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;
```
**2. System Optimization:**
```bash
# Increase file limits for chatwoot user
echo "chatwoot soft nofile 65536" | sudo tee -a /etc/security/limits.conf
echo "chatwoot hard nofile 65536" | sudo tee -a /etc/security/limits.conf
# Optimize PostgreSQL configuration
sudo nano /etc/postgresql/*/main/postgresql.conf
# Adjust shared_buffers, effective_cache_size, work_mem based on available RAM
```
### Security Hardening
**1. Firewall Configuration:**
```bash
# Install and configure UFW
sudo ufw enable
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
```
**2. Fail2ban Setup:**
```bash
# Install Fail2ban
sudo apt install -y fail2ban
# Configure Fail2ban for SSH
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
```
**3. Regular Updates:**
```bash
# Create update script
cat > /home/chatwoot/update_system.sh << 'EOF'
#!/bin/bash
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
sudo apt autoclean
EOF
chmod +x /home/chatwoot/update_system.sh
# Add to crontab for weekly updates
echo "0 2 * * 0 /home/chatwoot/update_system.sh" | sudo crontab -
```
---
<Warning>
Always test upgrades in a staging environment before applying to production. Keep regular backups of your database and application files.
</Warning>
<Note>
For high-availability deployments, consider setting up multiple servers with load balancing and database replication.
</Note>