Deploying a Chatwoot App
Introduction
Chatwoot is an open-source customer engagement platform that enables businesses to manage conversations across multiple channels including email, social media, live chat, and more. Built with Ruby on Rails and Vue.js, Chatwoot provides a unified inbox for customer support teams, real-time conversation management, automation capabilities, and comprehensive analytics.
Deploying Chatwoot on Klutch.sh gives you a reliable, scalable infrastructure for your customer support operations. Klutch.sh automatically detects and builds from your Dockerfile, handles HTTPS routing, and provides persistent storage for your conversation data, file uploads, and database. With support for both HTTP and TCP traffic routing, environment variable management, and easy scaling options, you can focus on delivering exceptional customer service while Klutch.sh manages the infrastructure.
This comprehensive guide walks you through deploying Chatwoot using a Dockerfile on Klutch.sh, from initial setup to production-ready configuration.
Prerequisites
Before you begin, ensure you have:
- A Klutch.sh account (sign up here)
- A GitHub account and repository for your Chatwoot deployment
- Basic understanding of Docker and containerization
- Familiarity with environment variables and web application configuration
- (Recommended for production) A PostgreSQL database instance
Understanding Chatwoot Architecture
Chatwoot consists of several components:
- Rails API Server: Backend application handling business logic and data
- Sidekiq Workers: Background job processing for async tasks
- PostgreSQL Database: Primary data storage
- Redis: Caching and real-time features
- File Storage: For attachments, avatars, and media files
For a production deployment, you’ll typically run the Rails server as your main application on Klutch.sh, with separate services for PostgreSQL and Redis.
Repository Setup
-
Create a new GitHub repository for your Chatwoot deployment or fork the official Chatwoot repository.
-
Clone the repository to your local machine:
Terminal window git clone https://github.com/your-username/chatwoot-deploy.gitcd chatwoot-deploy -
Create your Dockerfile in the root directory (see the next section for sample code).
-
Commit and push your changes to GitHub:
Terminal window git add .git commit -m "Add Dockerfile for Klutch.sh deployment"git push origin main
Important: Keep sensitive data like database credentials, API keys, and secret tokens out of your repository. These will be configured as environment variables in Klutch.sh.
Sample Dockerfile
Klutch.sh automatically detects a Dockerfile when present in the root directory of your repository. Here’s a production-ready Dockerfile for Chatwoot:
Basic Dockerfile (Using Official Image)
# Use the official Chatwoot image as baseFROM chatwoot/chatwoot:latest
# Set working directoryWORKDIR /app
# Expose the default Chatwoot portEXPOSE 3000
# The official image already includes the start command# Default: bundle exec rails s -p 3000 -b 0.0.0.0Advanced Dockerfile (Custom Build)
For more control over dependencies and configuration:
# Use Ruby base imageFROM ruby:3.2-slim
# Install dependenciesRUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ git \ nodejs \ npm \ postgresql-client \ imagemagick \ curl \ && rm -rf /var/lib/apt/lists/*
# Set working directoryWORKDIR /app
# Copy Gemfile and install gemsCOPY Gemfile Gemfile.lock ./RUN bundle install --jobs 4 --retry 3
# Copy package files and install Node dependenciesCOPY package.json yarn.lock ./RUN npm install -g yarn && yarn install
# Copy application codeCOPY . .
# Precompile assets for productionENV RAILS_ENV=productionRUN bundle exec rails assets:precompile
# Create necessary directoriesRUN mkdir -p /app/public/packs \ /app/tmp/pids \ /app/storage
# Expose portEXPOSE 3000
# Start commandCMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"]Dockerfile with Custom Start Script
If you need custom initialization logic:
FROM chatwoot/chatwoot:latest
WORKDIR /app
# Copy custom startup scriptCOPY docker-entrypoint.sh /usr/local/bin/RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["docker-entrypoint.sh"]CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"]docker-entrypoint.sh:
#!/bin/bashset -e
# Run database migrationsbundle exec rails db:migrate
# Precompile assets if neededif [ ! -f /app/tmp/.assets-compiled ]; then bundle exec rails assets:precompile touch /app/tmp/.assets-compiledfi
# Execute the main commandexec "$@"Deploying to Klutch.sh
Now that your repository is ready with a Dockerfile, follow these steps to deploy on Klutch.sh:
-
Log in to Klutch.sh Dashboard
Navigate to klutch.sh/app and sign in to your account.
-
Create a New Project (if you don’t have one already)
Click “New Project” and provide a name for your project (e.g., “Chatwoot Production”).
-
Create a New Application
- Click “New App” or “Create Application”
- Select HTTP as the traffic type (Chatwoot is a web application)
- Choose GitHub as your Git source
- Select your Chatwoot repository from the list
- Choose the branch you want to deploy (usually
mainormaster)
-
Configure Build Settings
Klutch.sh will automatically detect your Dockerfile in the root directory. The build process will:
- Clone your repository
- Build the Docker image using your Dockerfile
- Create a container from the image
- Start your application
-
Set Internal Port
Configure the internal port that your application listens on:
- Set the port to 3000 (Chatwoot’s default port)
- Klutch.sh will automatically route HTTP traffic from port 80/443 to this internal port
-
Configure Environment Variables (see detailed section below)
Add all required environment variables including database credentials, secret keys, and Chatwoot-specific configuration.
-
Deploy the Application
Click “Create” or “Deploy” to start the deployment process. Klutch.sh will build your Docker image and start the container.
-
Monitor Deployment
Watch the build logs to ensure the deployment completes successfully. Once deployed, your Chatwoot instance will be accessible at
https://your-app-name.klutch.shor your configured custom domain.
Persistent Storage Configuration
Chatwoot requires persistent storage for uploaded files, attachments, avatars, and other media. Without persistent volumes, these files would be lost when the container restarts.
-
Create a Persistent Volume
In the Klutch.sh dashboard, navigate to your application settings and locate the “Volumes” or “Storage” section.
-
Add Volume for Storage
- Click “Add Volume” or “Create Volume”
- Mount Path:
/app/storage - Size: Start with 10GB and increase based on your usage (recommend 50GB+ for production)
This directory will store all user uploads, file attachments, and media files.
-
Add Volume for Public Uploads (if using separate mount)
- Mount Path:
/app/public/uploads - Size: 5GB or more depending on expected traffic
- Mount Path:
-
Add Volume for Logs (optional but recommended)
- Mount Path:
/app/log - Size: 5GB
This helps preserve application logs across deployments.
- Mount Path:
-
Save Volume Configuration
Apply the changes. Klutch.sh will mount these volumes to your container, ensuring data persists across restarts and redeployments.
Important Notes:
- Volume data persists independently of your application container
- Regular backups of volume data are recommended for production environments
- Monitor volume usage and increase size as needed
- Ensure your application has proper write permissions to mounted directories
Environment Variables Configuration
Chatwoot requires numerous environment variables for proper operation. Configure these in the Klutch.sh dashboard under your application’s environment settings.
Required Environment Variables
Database Configuration
# PostgreSQL DatabaseDATABASE_URL=postgresql://username:password@host:5432/chatwoot_productionPOSTGRES_HOST=your-postgres-hostPOSTGRES_PORT=5432POSTGRES_DATABASE=chatwoot_productionPOSTGRES_USERNAME=chatwoot_userPOSTGRES_PASSWORD=your-secure-passwordRedis Configuration
REDIS_URL=redis://your-redis-host:6379REDIS_HOST=your-redis-hostREDIS_PORT=6379REDIS_PASSWORD=your-redis-passwordApplication Secrets
# Secret key for Rails (generate with: rails secret)SECRET_KEY_BASE=your-generated-secret-key-minimum-128-characters
# Frontend URL (your Klutch.sh app URL)FRONTEND_URL=https://example-app.klutch.sh
# Backend URLBACKEND_URL=https://example-app.klutch.shRails Environment
RAILS_ENV=productionRACK_ENV=productionNODE_ENV=productionRAILS_LOG_TO_STDOUT=trueOptional Environment Variables
Email Configuration (Recommended for production)
# SMTP SettingsSMTP_ADDRESS=smtp.gmail.comSMTP_PORT=587SMTP_DOMAIN=example.comSMTP_USERNAME=your-email@example.comSMTP_PASSWORD=your-email-passwordSMTP_AUTHENTICATION=plainSMTP_ENABLE_STARTTLS_AUTO=true
# Mailer configurationMAILER_SENDER_EMAIL=support@example.comMAILER_INBOUND_EMAIL_DOMAIN=example.comFile Storage (AWS S3 or Compatible)
# S3 Configuration (optional, for external storage)ACTIVE_STORAGE_SERVICE=amazonS3_BUCKET_NAME=your-bucket-nameAWS_ACCESS_KEY_ID=your-access-keyAWS_SECRET_ACCESS_KEY=your-secret-keyAWS_REGION=us-east-1Additional Features
# Enable featuresENABLE_ACCOUNT_SIGNUP=falseENABLE_ACCOUNT_SIGNUP=trueFORCE_SSL=true
# Chatwoot Installation NameINSTALLATION_NAME=Chatwoot
# Default localeDEFAULT_LOCALE=en
# Maximum file upload size (in MB)RAILS_MAX_FILE_SIZE=40Nixpacks Customization
If you need to customize the build or start commands using Nixpacks (Klutch.sh’s default build system), you can set these buildtime and runtime environment variables:
Custom Start Command
# Runtime environment variableNIXPACKS_START_CMD=bundle exec rails server -b 0.0.0.0 -p 3000Custom Build Command
# Buildtime environment variableNIXPACKS_BUILD_CMD=bundle install && yarn install && rails assets:precompileCustom Install Command
# Buildtime environment variableNIXPACKS_INSTALL_CMD=apt-get update && apt-get install -y libpq-dev imagemagickNote: When using a Dockerfile, Klutch.sh automatically uses Docker for building and running, so Nixpacks variables are not needed unless you’re deploying without a Dockerfile.
Database Setup
Chatwoot requires PostgreSQL as its primary database. You have two options:
Option 1: External Managed PostgreSQL
Use a managed PostgreSQL service (recommended for production):
- AWS RDS
- Google Cloud SQL
- DigitalOcean Managed Databases
- Heroku Postgres
- Supabase
Configure the DATABASE_URL environment variable with your managed database connection string.
Option 2: Deploy PostgreSQL on Klutch.sh
You can deploy PostgreSQL as a separate application on Klutch.sh:
-
Create a new application for PostgreSQL with TCP traffic type
-
Use a PostgreSQL Docker image:
FROM postgres:15-alpineENV POSTGRES_DB=chatwoot_productionENV POSTGRES_USER=chatwoot_user# Password should be set via Klutch.sh environment variablesEXPOSE 5432 -
Configure TCP Traffic
- Select TCP as the traffic type when creating the PostgreSQL app
- External connections will be available on port 8000
- Set the internal port to 5432 (PostgreSQL default)
-
Add Persistent Volume for database data:
- Mount Path:
/var/lib/postgresql/data - Size: 20GB minimum (scale based on expected data)
- Mount Path:
-
Connect from Chatwoot
Use the internal hostname provided by Klutch.sh to connect from your Chatwoot application.
Running Database Migrations
After deploying Chatwoot, you need to run database migrations. You can do this by:
- Adding a migration command to your
docker-entrypoint.shscript (recommended) - Connecting to your container and running manually:
bundle exec rails db:createbundle exec rails db:migratebundle exec rails db:seedRedis Setup
Chatwoot uses Redis for caching, background jobs, and real-time features. Similar to PostgreSQL, you have options:
Option 1: External Managed Redis
Use a managed Redis service:
- AWS ElastiCache
- Redis Labs
- Upstash
- DigitalOcean Managed Redis
Option 2: Deploy Redis on Klutch.sh
-
Create a new application for Redis with TCP traffic type
-
Use a Redis Dockerfile:
FROM redis:7-alpine# Optional: Add persistence configurationCOPY redis.conf /usr/local/etc/redis/redis.confEXPOSE 6379CMD ["redis-server", "/usr/local/etc/redis/redis.conf"] -
Configure TCP Traffic
- Select TCP as the traffic type
- External port: 8000
- Internal port: 6379
-
Add Persistent Volume (for data persistence):
- Mount Path:
/data - Size: 5GB
- Mount Path:
Getting Started with Chatwoot
Once your deployment is complete and all services are running:
-
Access Your Chatwoot Instance
Navigate to your application URL:
https://example-app.klutch.sh -
Create Administrator Account
On first access, you’ll be prompted to create an administrator account:
- Enter your name
- Provide email address
- Set a secure password
- Complete the setup wizard
-
Configure Your First Inbox
- Navigate to Settings → Inboxes
- Click “Add Inbox”
- Choose your channel type (Website, Email, API, etc.)
- Follow the setup wizard for your selected channel
-
Set Up Team Members
- Go to Settings → Agents
- Invite team members by email
- Assign roles and permissions
-
Customize Your Installation
- Upload your company logo
- Configure notification preferences
- Set up automation rules
- Customize widget appearance for website integration
-
Test Conversation Flow
- Send a test message through your configured inbox
- Verify notifications are working
- Test response and resolution workflow
Sample Widget Integration
To add Chatwoot to your website:
<script>(function(d,t) { var BASE_URL="https://example-app.klutch.sh"; var g=d.createElement(t),s=d.getElementsByTagName(t)[0]; g.src=BASE_URL+"/packs/js/sdk.js"; g.defer = true; g.async = true; s.parentNode.insertBefore(g,s); g.onload=function(){ window.chatwootSDK.run({ websiteToken: 'YOUR_WEBSITE_TOKEN', baseUrl: BASE_URL }) }})(document,"script");</script>Replace YOUR_WEBSITE_TOKEN with the token from your Chatwoot inbox settings.
Production Best Practices
Security
- Use HTTPS: Klutch.sh provides automatic HTTPS for your applications
- Strong Passwords: Use complex passwords for database and Redis
- Secret Management: Never commit secrets to your repository; use Klutch.sh environment variables
- Disable Public Signup: Set
ENABLE_ACCOUNT_SIGNUP=falsein production - Regular Updates: Keep Chatwoot, Ruby, and dependencies updated
- IP Restrictions: Consider restricting admin access to specific IP ranges
- 2FA: Enable two-factor authentication for admin accounts
Performance
- Database Connection Pooling: Configure appropriate connection pool sizes
- Redis Memory Management: Monitor and configure Redis memory limits
- Background Job Workers: Run separate Sidekiq worker processes for background jobs
- Asset CDN: Consider using a CDN for static assets and uploads
- Database Indexing: Ensure proper database indexes for frequently queried fields
- Caching: Leverage Redis caching for frequently accessed data
Monitoring and Maintenance
- Health Checks: Monitor application health endpoints
- Log Management: Regularly review and rotate logs
- Database Backups: Implement automated daily backups
- Volume Backups: Backup persistent volumes regularly
- Performance Metrics: Track response times, error rates, and resource usage
- Uptime Monitoring: Use external monitoring services
- Alert Configuration: Set up alerts for critical issues
Scaling Considerations
- Horizontal Scaling: Add more application instances for increased traffic
- Vertical Scaling: Increase resources (CPU, RAM) for existing instances
- Database Scaling: Use read replicas for database scaling
- Load Balancing: Distribute traffic across multiple instances
- Stateless Architecture: Keep application servers stateless
- Session Storage: Use Redis for session storage across instances
- File Storage: Use external storage (S3) for uploads when scaling horizontally
Backup Strategy
Implement a comprehensive backup strategy:
- Database Backups: Daily automated PostgreSQL backups
- Volume Snapshots: Weekly snapshots of persistent volumes
- Configuration Backup: Store environment variable configurations securely
- Disaster Recovery Plan: Document and test recovery procedures
- Retention Policy: Keep backups for at least 30 days
Customization Options
Branding
Customize Chatwoot to match your brand:
- Upload custom logo in Settings
- Configure brand colors
- Customize email templates
- White-label the widget
Custom Integrations
Chatwoot supports numerous integrations:
- Slack
- WhatsApp Business
- Facebook Messenger
- Telegram
- Email (IMAP/SMTP)
- API webhooks for custom integrations
Automation
Set up automation rules:
- Auto-assignment based on team availability
- Automatic responses for common queries
- Escalation rules for urgent issues
- CSAT survey automation
- SLA management
Troubleshooting
Common Issues and Solutions
Application Won’t Start
- Check logs in Klutch.sh dashboard for error messages
- Verify environment variables are correctly set
- Ensure database is accessible and migrations have run
- Check port configuration matches your Dockerfile EXPOSE statement
Database Connection Errors
- Verify DATABASE_URL format is correct
- Check database credentials are accurate
- Ensure database is running and accessible
- Test connection from your application container
- Check network connectivity between services
File Upload Issues
- Verify persistent volume is mounted correctly
- Check mount path matches Chatwoot’s storage configuration
- Ensure sufficient disk space in volume
- Verify file permissions on mounted directories
- Check RAILS_MAX_FILE_SIZE environment variable
Redis Connection Problems
- Verify REDIS_URL is correctly formatted
- Check Redis service is running
- Test connectivity from application container
- Verify Redis password if authentication is enabled
Performance Issues
- Monitor resource usage (CPU, RAM, disk I/O)
- Check database performance and query optimization
- Review Sidekiq worker performance and queue sizes
- Analyze slow logs to identify bottlenecks
- Consider scaling resources or adding instances
Email Delivery Issues
- Verify SMTP settings are correct
- Check email provider allows SMTP connections
- Test email credentials independently
- Review email logs for delivery errors
- Check spam filters and email reputation
Monitoring and Observability
Application Logs
Access logs through:
- Klutch.sh dashboard log viewer
- Mounted log volume at
/app/log - STDOUT/STDERR (with
RAILS_LOG_TO_STDOUT=true)
Key Metrics to Monitor
- Response Time: Monitor API and page load times
- Error Rate: Track 4xx and 5xx errors
- Throughput: Messages processed per minute
- Database Performance: Query time and connection pool usage
- Background Jobs: Sidekiq queue depth and processing time
- Memory Usage: Application and database memory consumption
- Disk Usage: Volume capacity and I/O operations
Recommended Monitoring Tools
- Application Performance: New Relic, Datadog, Scout APM
- Error Tracking: Sentry, Rollbar
- Uptime Monitoring: UptimeRobot, Pingdom
- Log Aggregation: Papertrail, Loggly
- Infrastructure: Klutch.sh built-in metrics
Upgrading Chatwoot
To upgrade to a newer version of Chatwoot:
-
Review Release Notes
Check the Chatwoot releases page for breaking changes and migration notes.
-
Update Dockerfile
Change the version tag in your Dockerfile:
FROM chatwoot/chatwoot:v3.0.0 -
Backup Everything
- Create database backup
- Snapshot persistent volumes
- Export configuration
-
Deploy Updated Version
Commit and push your Dockerfile changes. Klutch.sh will automatically rebuild and redeploy.
-
Run Migrations
If your entrypoint script includes migrations, they’ll run automatically. Otherwise, run manually:
Terminal window bundle exec rails db:migrate -
Verify Functionality
- Test all critical features
- Check integrations are working
- Verify data integrity
- Monitor logs for errors
Cost Optimization
Tips for Reducing Costs
- Right-Size Resources: Start small and scale based on actual usage
- Volume Management: Regularly clean up old attachments and logs
- Database Optimization: Archive old conversations to reduce database size
- Efficient Caching: Proper Redis configuration reduces database load
- Image Optimization: Compress and optimize uploaded images
- CDN Usage: Serve static assets from a CDN to reduce bandwidth costs
Additional Resources
Official Documentation
Klutch.sh Documentation
- Klutch.sh Quick Start Guide
- Persistent Volumes Guide
- Environment Variables Guide
- Custom Domains Configuration
Community Resources
Conclusion
Deploying Chatwoot on Klutch.sh provides a powerful, scalable solution for customer engagement and support. With automatic Dockerfile detection, persistent storage, and easy environment configuration, you can have a production-ready Chatwoot instance running quickly. The platform handles infrastructure complexities, allowing you to focus on delivering exceptional customer experiences.
By following this guide, you’ve learned how to:
- Set up a Chatwoot deployment with a Dockerfile
- Configure persistent storage for uploads and data
- Manage environment variables and secrets
- Set up PostgreSQL and Redis services
- Implement production best practices
- Monitor and maintain your deployment
For advanced configurations, custom integrations, or scaling needs, refer to the official Chatwoot documentation and Klutch.sh support resources. Happy deploying!