add mintlify intro docs
This commit is contained in:
@@ -0,0 +1,501 @@
|
||||
---
|
||||
title: AWS Deployment
|
||||
description: Deploy Chatwoot on Amazon Web Services with manual installation or marketplace AMI
|
||||
sidebarTitle: AWS
|
||||
---
|
||||
|
||||
# AWS Deployment Guide
|
||||
|
||||
Deploy Chatwoot on Amazon Web Services (AWS) using either manual installation or the AWS Marketplace AMI for a scalable, production-ready setup.
|
||||
|
||||
## Deployment Options
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Manual Installation" icon="code" href="#manual-installation">
|
||||
Full control over the deployment with custom architecture
|
||||
</Card>
|
||||
<Card title="AWS Marketplace AMI" icon="aws" href="#aws-marketplace-ami">
|
||||
Quick deployment using pre-configured AMI
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Manual Installation
|
||||
|
||||
### Architecture Overview
|
||||
|
||||
This guide follows a standard 3-tier architecture on AWS for high availability:
|
||||
|
||||
```
|
||||
Internet Gateway
|
||||
|
|
||||
Application Load Balancer (Public Subnets)
|
||||
|
|
||||
Chatwoot Instances (Private Subnets)
|
||||
|
|
||||
RDS PostgreSQL + ElastiCache Redis (Private Subnets)
|
||||
```
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- AWS account with appropriate permissions
|
||||
- Domain name for your Chatwoot installation
|
||||
- Basic knowledge of AWS services (VPC, EC2, RDS, etc.)
|
||||
|
||||
### Step 1: Network Setup
|
||||
|
||||
#### Create VPC
|
||||
|
||||
1. Navigate to the VPC console in your chosen AWS region
|
||||
2. Create a new VPC:
|
||||
- **Name**: `chatwoot-vpc`
|
||||
- **CIDR block**: `10.0.0.0/16`
|
||||
- Leave other options as default
|
||||
|
||||
#### Create Subnets
|
||||
|
||||
Create subnets across two availability zones:
|
||||
|
||||
| Name | Type | AZ | CIDR Block |
|
||||
|------|------|----|-----------|
|
||||
| chatwoot-public-1 | Public | us-east-1a | 10.0.0.0/24 |
|
||||
| chatwoot-public-2 | Public | us-east-1b | 10.0.1.0/24 |
|
||||
| chatwoot-private-1 | Private | us-east-1a | 10.0.2.0/24 |
|
||||
| chatwoot-private-2 | Private | us-east-1b | 10.0.3.0/24 |
|
||||
|
||||
<Note>
|
||||
Enable "Auto-assign public IPv4 address" for public subnets under Actions > Subnet Settings.
|
||||
</Note>
|
||||
|
||||
#### Internet Gateway
|
||||
|
||||
1. Create Internet Gateway named `chatwoot-igw`
|
||||
2. Attach it to `chatwoot-vpc`
|
||||
|
||||
#### NAT Gateways
|
||||
|
||||
Create NAT gateways in each public subnet:
|
||||
|
||||
1. **chatwoot-nat-1** in `chatwoot-public-1`
|
||||
2. **chatwoot-nat-2** in `chatwoot-public-2`
|
||||
|
||||
Allocate Elastic IPs for each NAT gateway.
|
||||
|
||||
#### Route Tables
|
||||
|
||||
**Public Route Table** (`chatwoot-public-rt`):
|
||||
- Route: `0.0.0.0/0` → `chatwoot-igw`
|
||||
- Associate with public subnets
|
||||
|
||||
**Private Route Tables**:
|
||||
- `chatwoot-private-a`: Route `0.0.0.0/0` → `chatwoot-nat-1`
|
||||
- `chatwoot-private-b`: Route `0.0.0.0/0` → `chatwoot-nat-2`
|
||||
|
||||
### Step 2: Application Load Balancer
|
||||
|
||||
1. Navigate to EC2 > Load Balancers
|
||||
2. Create Application Load Balancer:
|
||||
- **Name**: `chatwoot-loadbalancer`
|
||||
- **Scheme**: Internet-facing
|
||||
- **IP address type**: IPv4
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnets**: Select both public subnets
|
||||
|
||||
#### Security Group for ALB
|
||||
|
||||
Create `chatwoot-loadbalancer-sg` with rules:
|
||||
- HTTP (80) from `0.0.0.0/0`
|
||||
- HTTPS (443) from `0.0.0.0/0`
|
||||
- TCP (3000) from `0.0.0.0/0` (for health checks)
|
||||
|
||||
#### Target Group
|
||||
|
||||
Create `chatwoot-tg` target group:
|
||||
- **Target type**: Instances
|
||||
- **Protocol**: HTTP
|
||||
- **Port**: 3000
|
||||
- **Health check path**: `/api`
|
||||
|
||||
### Step 3: Database Setup (RDS)
|
||||
|
||||
#### RDS Security Group
|
||||
|
||||
Create `chatwoot-rds-sg`:
|
||||
- PostgreSQL (5432) from `chatwoot-loadbalancer-sg`
|
||||
|
||||
#### RDS Subnet Group
|
||||
|
||||
Create `chatwoot-rds-group`:
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnets**: Both private subnets
|
||||
|
||||
#### Create RDS Instance
|
||||
|
||||
1. Navigate to RDS > Databases
|
||||
2. Create database:
|
||||
- **Engine**: PostgreSQL
|
||||
- **Template**: Production
|
||||
- **DB instance identifier**: `chatwoot-db`
|
||||
- **Master username**: `chatwoot`
|
||||
- **Master password**: Generate secure password
|
||||
- **DB instance class**: `db.t3.medium` (minimum)
|
||||
- **Storage**: 100 GB GP2 (minimum)
|
||||
- **Multi-AZ**: Yes
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnet group**: `chatwoot-rds-group`
|
||||
- **Security group**: `chatwoot-rds-sg`
|
||||
|
||||
<Warning>
|
||||
Note down the RDS endpoint, username, and password for later configuration.
|
||||
</Warning>
|
||||
|
||||
### Step 4: Redis Setup (ElastiCache)
|
||||
|
||||
#### ElastiCache Security Group
|
||||
|
||||
Create `chatwoot-redis-sg`:
|
||||
- Redis (6379) from `chatwoot-loadbalancer-sg`
|
||||
|
||||
#### ElastiCache Subnet Group
|
||||
|
||||
Create `chatwoot-redis-group`:
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnets**: Both private subnets
|
||||
|
||||
#### Create Redis Cluster
|
||||
|
||||
1. Navigate to ElastiCache > Redis clusters
|
||||
2. Create cluster:
|
||||
- **Name**: `chatwoot-redis`
|
||||
- **Engine version**: 7.0+
|
||||
- **Node type**: `cache.t3.micro` (minimum)
|
||||
- **Multi-AZ**: Yes
|
||||
- **Subnet group**: `chatwoot-redis-group`
|
||||
- **Security group**: `chatwoot-redis-sg`
|
||||
|
||||
### Step 5: Bastion Host
|
||||
|
||||
Create bastion servers for secure access to private instances:
|
||||
|
||||
1. Launch EC2 instance:
|
||||
- **AMI**: Ubuntu 20.04 LTS
|
||||
- **Instance type**: `t3.micro`
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnet**: `chatwoot-public-1`
|
||||
- **Auto-assign public IP**: Yes
|
||||
- **Security group**: Create `chatwoot-bastion-sg` (SSH from your IP)
|
||||
|
||||
### Step 6: Chatwoot Application Servers
|
||||
|
||||
#### Launch Chatwoot Instance
|
||||
|
||||
1. Launch EC2 instance:
|
||||
- **AMI**: Ubuntu 20.04 LTS
|
||||
- **Instance type**: `c5.xlarge` (minimum for production)
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnet**: `chatwoot-private-1`
|
||||
- **Auto-assign public IP**: No
|
||||
- **Storage**: 60 GB GP2
|
||||
- **Security group**: `chatwoot-loadbalancer-sg`
|
||||
|
||||
#### Install Chatwoot
|
||||
|
||||
1. SSH to bastion host, then to Chatwoot instance
|
||||
2. Switch to root user and download installation script:
|
||||
|
||||
```bash
|
||||
sudo su -
|
||||
wget https://get.chatwoot.app/linux/install.sh
|
||||
chmod +x install.sh
|
||||
./install.sh --install
|
||||
```
|
||||
|
||||
#### Configure Chatwoot
|
||||
|
||||
1. Switch to chatwoot user and edit environment:
|
||||
|
||||
```bash
|
||||
sudo -i -u chatwoot
|
||||
cd chatwoot
|
||||
nano .env
|
||||
```
|
||||
|
||||
2. Update database and Redis configuration:
|
||||
|
||||
```bash
|
||||
# Database
|
||||
DATABASE_URL="postgresql://chatwoot:password@your-rds-endpoint:5432/chatwoot_production"
|
||||
|
||||
# Redis
|
||||
REDIS_URL="redis://your-elasticache-endpoint:6379/0"
|
||||
|
||||
# Frontend URL
|
||||
FRONTEND_URL="https://chatwoot.yourdomain.com"
|
||||
|
||||
# Force SSL
|
||||
FORCE_SSL=true
|
||||
|
||||
# Email configuration (example with SES)
|
||||
MAILER_SENDER_EMAIL="noreply@yourdomain.com"
|
||||
SMTP_ADDRESS="email-smtp.us-east-1.amazonaws.com"
|
||||
SMTP_PORT=587
|
||||
SMTP_USERNAME="your-ses-username"
|
||||
SMTP_PASSWORD="your-ses-password"
|
||||
SMTP_AUTHENTICATION="plain"
|
||||
SMTP_ENABLE_STARTTLS_AUTO=true
|
||||
|
||||
# Storage (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"
|
||||
```
|
||||
|
||||
3. Run database preparation:
|
||||
|
||||
```bash
|
||||
RAILS_ENV=production bundle exec rake db:chatwoot_prepare
|
||||
```
|
||||
|
||||
4. Restart services:
|
||||
|
||||
```bash
|
||||
sudo cwctl --restart
|
||||
```
|
||||
|
||||
### Step 7: SSL Certificate (ACM)
|
||||
|
||||
1. Navigate to Certificate Manager
|
||||
2. Request public certificate for your domain
|
||||
3. Validate domain ownership
|
||||
4. Attach certificate to ALB HTTPS listener
|
||||
|
||||
### Step 8: Auto Scaling
|
||||
|
||||
#### Create AMI
|
||||
|
||||
1. Stop the Chatwoot instance
|
||||
2. Create AMI named `chatwoot-base-ami`
|
||||
3. Terminate the original instance
|
||||
|
||||
#### Launch Template
|
||||
|
||||
Create launch template with:
|
||||
- **AMI**: `chatwoot-base-ami`
|
||||
- **Instance type**: `c5.xlarge`
|
||||
- **Security group**: `chatwoot-loadbalancer-sg`
|
||||
- **User data** (optional):
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
sudo cwctl --restart
|
||||
```
|
||||
|
||||
#### Auto Scaling Group
|
||||
|
||||
Create ASG with:
|
||||
- **Launch template**: Use created template
|
||||
- **VPC**: `chatwoot-vpc`
|
||||
- **Subnets**: Both private subnets
|
||||
- **Target group**: `chatwoot-tg`
|
||||
- **Desired capacity**: 2
|
||||
- **Minimum**: 2
|
||||
- **Maximum**: 4
|
||||
|
||||
#### Scaling Policies
|
||||
|
||||
Create scaling policies based on:
|
||||
- CPU utilization (scale out at 70%, scale in at 30%)
|
||||
- Memory utilization
|
||||
- Request count per target
|
||||
|
||||
## AWS Marketplace AMI
|
||||
|
||||
### Quick Deployment
|
||||
|
||||
1. Navigate to AWS Marketplace
|
||||
2. Search for "Chatwoot"
|
||||
3. Subscribe to Chatwoot AMI
|
||||
4. Launch instance with recommended settings:
|
||||
- **Instance type**: `t3.medium` or larger
|
||||
- **Storage**: 20 GB minimum
|
||||
- **Security group**: Allow HTTP, HTTPS, and SSH
|
||||
|
||||
### Post-Launch Configuration
|
||||
|
||||
1. SSH to the instance
|
||||
2. Complete initial setup:
|
||||
|
||||
```bash
|
||||
sudo /opt/chatwoot/setup.sh
|
||||
```
|
||||
|
||||
3. Configure domain and SSL:
|
||||
|
||||
```bash
|
||||
sudo /opt/chatwoot/configure-domain.sh yourdomain.com
|
||||
```
|
||||
|
||||
## Production Optimizations
|
||||
|
||||
### Performance Tuning
|
||||
|
||||
```bash
|
||||
# Optimize Rails configuration
|
||||
export RAILS_MAX_THREADS=20
|
||||
export WEB_CONCURRENCY=4
|
||||
export SIDEKIQ_CONCURRENCY=25
|
||||
|
||||
# Database connection pooling
|
||||
export DATABASE_POOL_SIZE=25
|
||||
```
|
||||
|
||||
### Monitoring Setup
|
||||
|
||||
#### CloudWatch Metrics
|
||||
|
||||
Enable detailed monitoring for:
|
||||
- EC2 instances
|
||||
- RDS database
|
||||
- ElastiCache cluster
|
||||
- Application Load Balancer
|
||||
|
||||
#### Custom Metrics
|
||||
|
||||
```bash
|
||||
# Install CloudWatch agent
|
||||
wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
|
||||
sudo rpm -U ./amazon-cloudwatch-agent.rpm
|
||||
|
||||
# Configure custom metrics
|
||||
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
|
||||
```
|
||||
|
||||
### Backup Strategy
|
||||
|
||||
#### RDS Automated Backups
|
||||
|
||||
- Enable automated backups with 7-day retention
|
||||
- Configure backup window during low-traffic hours
|
||||
- Enable point-in-time recovery
|
||||
|
||||
#### Application Data Backup
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Backup script for application data
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
# Database backup
|
||||
pg_dump $DATABASE_URL | gzip > "s3://your-backup-bucket/db/chatwoot_$DATE.sql.gz"
|
||||
|
||||
# File uploads backup (if using local storage)
|
||||
aws s3 sync /home/chatwoot/chatwoot/storage s3://your-backup-bucket/storage/
|
||||
```
|
||||
|
||||
### Security Hardening
|
||||
|
||||
#### IAM Roles
|
||||
|
||||
Create IAM roles with minimal permissions:
|
||||
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:PutObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": "arn:aws:s3:::your-chatwoot-bucket/*"
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"ses:SendEmail",
|
||||
"ses:SendRawEmail"
|
||||
],
|
||||
"Resource": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Security Groups
|
||||
|
||||
Implement least-privilege access:
|
||||
- ALB: Only HTTP/HTTPS from internet
|
||||
- App servers: Only from ALB and bastion
|
||||
- Database: Only from app servers
|
||||
- Redis: Only from app servers
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
### Reserved Instances
|
||||
|
||||
Purchase Reserved Instances for:
|
||||
- RDS database instances
|
||||
- ElastiCache clusters
|
||||
- Predictable EC2 workloads
|
||||
|
||||
### Spot Instances
|
||||
|
||||
Use Spot Instances for:
|
||||
- Development environments
|
||||
- Non-critical worker processes
|
||||
- Batch processing tasks
|
||||
|
||||
### Storage Optimization
|
||||
|
||||
- Use GP3 volumes for better price/performance
|
||||
- Implement S3 lifecycle policies for old backups
|
||||
- Use S3 Intelligent Tiering for file storage
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
<Accordion title="Application not accessible">
|
||||
Check:
|
||||
- Security group rules
|
||||
- Target group health
|
||||
- Route table configuration
|
||||
- DNS resolution
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Database connection errors">
|
||||
Verify:
|
||||
- RDS security group allows connections
|
||||
- Database credentials in .env file
|
||||
- Network connectivity from app servers
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="High memory usage">
|
||||
Solutions:
|
||||
- Increase instance size
|
||||
- Optimize Sidekiq concurrency
|
||||
- Enable swap memory
|
||||
- Monitor for memory leaks
|
||||
</Accordion>
|
||||
|
||||
### Monitoring Commands
|
||||
|
||||
```bash
|
||||
# Check application health
|
||||
curl -I http://localhost:3000/api
|
||||
|
||||
# Monitor system resources
|
||||
htop
|
||||
iostat -x 1
|
||||
free -h
|
||||
|
||||
# Check service status
|
||||
sudo systemctl status chatwoot.target
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
This AWS deployment guide provides a comprehensive approach to hosting Chatwoot on AWS infrastructure. Choose the deployment method that best fits your requirements and scale as needed.
|
||||
@@ -0,0 +1,663 @@
|
||||
---
|
||||
title: Azure Deployment
|
||||
description: Deploy Chatwoot on Microsoft Azure with various deployment options
|
||||
sidebarTitle: Azure
|
||||
---
|
||||
|
||||
# Azure Deployment Guide
|
||||
|
||||
Deploy Chatwoot on Microsoft Azure using various deployment options including Virtual Machines, Container Instances, or App Service for a scalable, production-ready setup.
|
||||
|
||||
## Deployment Options
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Virtual Machines" icon="server" href="#virtual-machines">
|
||||
Full control with custom VM deployment
|
||||
</Card>
|
||||
<Card title="Container Instances" icon="docker" href="#container-instances">
|
||||
Serverless container deployment
|
||||
</Card>
|
||||
<Card title="App Service" icon="cloud" href="#app-service">
|
||||
Platform-as-a-Service deployment
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Virtual Machines Deployment
|
||||
|
||||
### Architecture Overview
|
||||
|
||||
```
|
||||
Azure Load Balancer
|
||||
|
|
||||
Virtual Machines (Availability Set)
|
||||
|
|
||||
Azure Database for PostgreSQL + Azure Cache for Redis
|
||||
```
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Azure subscription with appropriate permissions
|
||||
- Azure CLI installed and configured
|
||||
- Domain name for your Chatwoot installation
|
||||
|
||||
### Step 1: Resource Group and Network
|
||||
|
||||
#### Create Resource Group
|
||||
|
||||
```bash
|
||||
# Create resource group
|
||||
az group create \
|
||||
--name chatwoot-rg \
|
||||
--location eastus
|
||||
```
|
||||
|
||||
#### Create Virtual Network
|
||||
|
||||
```bash
|
||||
# Create virtual network
|
||||
az network vnet create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vnet \
|
||||
--address-prefix 10.0.0.0/16 \
|
||||
--subnet-name chatwoot-subnet \
|
||||
--subnet-prefix 10.0.1.0/24
|
||||
```
|
||||
|
||||
#### Create Network Security Group
|
||||
|
||||
```bash
|
||||
# Create NSG
|
||||
az network nsg create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-nsg
|
||||
|
||||
# Add rules
|
||||
az network nsg rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--nsg-name chatwoot-nsg \
|
||||
--name AllowHTTP \
|
||||
--protocol tcp \
|
||||
--priority 1000 \
|
||||
--destination-port-range 80
|
||||
|
||||
az network nsg rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--nsg-name chatwoot-nsg \
|
||||
--name AllowHTTPS \
|
||||
--protocol tcp \
|
||||
--priority 1001 \
|
||||
--destination-port-range 443
|
||||
|
||||
az network nsg rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--nsg-name chatwoot-nsg \
|
||||
--name AllowSSH \
|
||||
--protocol tcp \
|
||||
--priority 1002 \
|
||||
--destination-port-range 22 \
|
||||
--source-address-prefix "YOUR_IP_ADDRESS"
|
||||
```
|
||||
|
||||
### Step 2: Database Setup
|
||||
|
||||
#### Create PostgreSQL Server
|
||||
|
||||
```bash
|
||||
# Create PostgreSQL server
|
||||
az postgres server create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-postgres \
|
||||
--location eastus \
|
||||
--admin-user chatwoot \
|
||||
--admin-password "YourSecurePassword123!" \
|
||||
--sku-name GP_Gen5_2 \
|
||||
--version 13
|
||||
|
||||
# Create database
|
||||
az postgres db create \
|
||||
--resource-group chatwoot-rg \
|
||||
--server-name chatwoot-postgres \
|
||||
--name chatwoot_production
|
||||
|
||||
# Configure firewall
|
||||
az postgres server firewall-rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--server chatwoot-postgres \
|
||||
--name AllowAzureServices \
|
||||
--start-ip-address 0.0.0.0 \
|
||||
--end-ip-address 0.0.0.0
|
||||
```
|
||||
|
||||
#### Create Redis Cache
|
||||
|
||||
```bash
|
||||
# Create Redis cache
|
||||
az redis create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-redis \
|
||||
--location eastus \
|
||||
--sku Basic \
|
||||
--vm-size c0
|
||||
```
|
||||
|
||||
### Step 3: Storage Account
|
||||
|
||||
```bash
|
||||
# Create storage account
|
||||
az storage account create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwootstorage \
|
||||
--location eastus \
|
||||
--sku Standard_LRS
|
||||
|
||||
# Create container for file uploads
|
||||
az storage container create \
|
||||
--account-name chatwootstorage \
|
||||
--name uploads \
|
||||
--public-access blob
|
||||
```
|
||||
|
||||
### Step 4: Virtual Machine
|
||||
|
||||
#### Create Availability Set
|
||||
|
||||
```bash
|
||||
# Create availability set
|
||||
az vm availability-set create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-avset \
|
||||
--platform-fault-domain-count 2 \
|
||||
--platform-update-domain-count 2
|
||||
```
|
||||
|
||||
#### Create Virtual Machine
|
||||
|
||||
```bash
|
||||
# Create VM
|
||||
az vm create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vm \
|
||||
--image UbuntuLTS \
|
||||
--size Standard_D2s_v3 \
|
||||
--availability-set chatwoot-avset \
|
||||
--vnet-name chatwoot-vnet \
|
||||
--subnet chatwoot-subnet \
|
||||
--nsg chatwoot-nsg \
|
||||
--admin-username azureuser \
|
||||
--generate-ssh-keys \
|
||||
--custom-data cloud-init.txt
|
||||
```
|
||||
|
||||
#### Cloud-Init Configuration
|
||||
|
||||
Create `cloud-init.txt`:
|
||||
|
||||
```yaml
|
||||
#cloud-config
|
||||
package_upgrade: true
|
||||
packages:
|
||||
- curl
|
||||
- wget
|
||||
- git
|
||||
|
||||
runcmd:
|
||||
- wget https://get.chatwoot.app/linux/install.sh
|
||||
- chmod +x install.sh
|
||||
- ./install.sh --install
|
||||
```
|
||||
|
||||
### Step 5: Load Balancer
|
||||
|
||||
```bash
|
||||
# Create public IP
|
||||
az network public-ip create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-lb-ip \
|
||||
--sku Standard
|
||||
|
||||
# Create load balancer
|
||||
az network lb create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-lb \
|
||||
--public-ip-address chatwoot-lb-ip \
|
||||
--frontend-ip-name chatwoot-frontend \
|
||||
--backend-pool-name chatwoot-backend
|
||||
|
||||
# Create health probe
|
||||
az network lb probe create \
|
||||
--resource-group chatwoot-rg \
|
||||
--lb-name chatwoot-lb \
|
||||
--name chatwoot-health \
|
||||
--protocol http \
|
||||
--port 3000 \
|
||||
--path /api
|
||||
|
||||
# Create load balancing rule
|
||||
az network lb rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--lb-name chatwoot-lb \
|
||||
--name chatwoot-rule \
|
||||
--protocol tcp \
|
||||
--frontend-port 80 \
|
||||
--backend-port 3000 \
|
||||
--frontend-ip-name chatwoot-frontend \
|
||||
--backend-pool-name chatwoot-backend \
|
||||
--probe-name chatwoot-health
|
||||
```
|
||||
|
||||
### Step 6: Configuration
|
||||
|
||||
SSH to the VM and configure Chatwoot:
|
||||
|
||||
```bash
|
||||
# SSH to VM
|
||||
ssh azureuser@<VM_PUBLIC_IP>
|
||||
|
||||
# Switch to chatwoot user
|
||||
sudo -i -u chatwoot
|
||||
cd chatwoot
|
||||
|
||||
# Edit environment variables
|
||||
nano .env
|
||||
```
|
||||
|
||||
Update `.env` with Azure services:
|
||||
|
||||
```bash
|
||||
# Database
|
||||
DATABASE_URL="postgresql://chatwoot:YourSecurePassword123!@chatwoot-postgres.postgres.database.azure.com:5432/chatwoot_production"
|
||||
|
||||
# Redis
|
||||
REDIS_URL="redis://:PRIMARY_ACCESS_KEY@chatwoot-redis.redis.cache.windows.net:6380/0?ssl=true"
|
||||
|
||||
# Storage (Azure Blob)
|
||||
ACTIVE_STORAGE_SERVICE="azure"
|
||||
AZURE_STORAGE_ACCOUNT_NAME="chatwootstorage"
|
||||
AZURE_STORAGE_ACCESS_KEY="your-access-key"
|
||||
AZURE_STORAGE_CONTAINER="uploads"
|
||||
|
||||
# Frontend URL
|
||||
FRONTEND_URL="https://chatwoot.yourdomain.com"
|
||||
FORCE_SSL=true
|
||||
```
|
||||
|
||||
## Container Instances Deployment
|
||||
|
||||
### Docker Compose for Azure
|
||||
|
||||
Create `docker-compose.azure.yml`:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
chatwoot-web:
|
||||
image: chatwoot/chatwoot:latest
|
||||
environment:
|
||||
- RAILS_ENV=production
|
||||
- DATABASE_URL=postgresql://chatwoot:password@postgres:5432/chatwoot_production
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- FRONTEND_URL=https://chatwoot.yourdomain.com
|
||||
- FORCE_SSL=true
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
|
||||
chatwoot-worker:
|
||||
image: chatwoot/chatwoot:latest
|
||||
environment:
|
||||
- RAILS_ENV=production
|
||||
- DATABASE_URL=postgresql://chatwoot:password@postgres:5432/chatwoot_production
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
command: bundle exec sidekiq -C config/sidekiq.yml
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
|
||||
postgres:
|
||||
image: postgres:13
|
||||
environment:
|
||||
- POSTGRES_DB=chatwoot_production
|
||||
- POSTGRES_USER=chatwoot
|
||||
- POSTGRES_PASSWORD=password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
```
|
||||
|
||||
### Deploy with Azure Container Instances
|
||||
|
||||
```bash
|
||||
# Create container group
|
||||
az container create \
|
||||
--resource-group chatwoot-rg \
|
||||
--file docker-compose.azure.yml \
|
||||
--dns-name-label chatwoot-app \
|
||||
--ports 3000
|
||||
```
|
||||
|
||||
## App Service Deployment
|
||||
|
||||
### Create App Service Plan
|
||||
|
||||
```bash
|
||||
# Create App Service plan
|
||||
az appservice plan create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-plan \
|
||||
--sku P1V2 \
|
||||
--is-linux
|
||||
|
||||
# Create web app
|
||||
az webapp create \
|
||||
--resource-group chatwoot-rg \
|
||||
--plan chatwoot-plan \
|
||||
--name chatwoot-app \
|
||||
--deployment-container-image-name chatwoot/chatwoot:latest
|
||||
```
|
||||
|
||||
### Configure App Settings
|
||||
|
||||
```bash
|
||||
# Set environment variables
|
||||
az webapp config appsettings set \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-app \
|
||||
--settings \
|
||||
RAILS_ENV=production \
|
||||
DATABASE_URL="postgresql://chatwoot:password@chatwoot-postgres.postgres.database.azure.com:5432/chatwoot_production" \
|
||||
REDIS_URL="redis://:key@chatwoot-redis.redis.cache.windows.net:6380/0?ssl=true" \
|
||||
FRONTEND_URL="https://chatwoot-app.azurewebsites.net" \
|
||||
FORCE_SSL=true
|
||||
```
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
### Application Insights
|
||||
|
||||
```bash
|
||||
# Create Application Insights
|
||||
az monitor app-insights component create \
|
||||
--resource-group chatwoot-rg \
|
||||
--app chatwoot-insights \
|
||||
--location eastus \
|
||||
--kind web
|
||||
|
||||
# Get instrumentation key
|
||||
az monitor app-insights component show \
|
||||
--resource-group chatwoot-rg \
|
||||
--app chatwoot-insights \
|
||||
--query instrumentationKey
|
||||
```
|
||||
|
||||
### Log Analytics Workspace
|
||||
|
||||
```bash
|
||||
# Create Log Analytics workspace
|
||||
az monitor log-analytics workspace create \
|
||||
--resource-group chatwoot-rg \
|
||||
--workspace-name chatwoot-logs \
|
||||
--location eastus
|
||||
```
|
||||
|
||||
## Security Configuration
|
||||
|
||||
### Key Vault for Secrets
|
||||
|
||||
```bash
|
||||
# Create Key Vault
|
||||
az keyvault create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vault \
|
||||
--location eastus
|
||||
|
||||
# Store secrets
|
||||
az keyvault secret set \
|
||||
--vault-name chatwoot-vault \
|
||||
--name database-password \
|
||||
--value "YourSecurePassword123!"
|
||||
|
||||
az keyvault secret set \
|
||||
--vault-name chatwoot-vault \
|
||||
--name redis-key \
|
||||
--value "your-redis-access-key"
|
||||
```
|
||||
|
||||
### Managed Identity
|
||||
|
||||
```bash
|
||||
# Enable managed identity for VM
|
||||
az vm identity assign \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vm
|
||||
|
||||
# Grant access to Key Vault
|
||||
az keyvault set-policy \
|
||||
--name chatwoot-vault \
|
||||
--object-id <MANAGED_IDENTITY_PRINCIPAL_ID> \
|
||||
--secret-permissions get list
|
||||
```
|
||||
|
||||
## Backup and Disaster Recovery
|
||||
|
||||
### Database Backup
|
||||
|
||||
```bash
|
||||
# Enable automated backup for PostgreSQL
|
||||
az postgres server configuration set \
|
||||
--resource-group chatwoot-rg \
|
||||
--server-name chatwoot-postgres \
|
||||
--name backup_retention_days \
|
||||
--value 7
|
||||
|
||||
# Create manual backup
|
||||
az postgres server backup create \
|
||||
--resource-group chatwoot-rg \
|
||||
--server-name chatwoot-postgres \
|
||||
--backup-name manual-backup-$(date +%Y%m%d)
|
||||
```
|
||||
|
||||
### VM Backup
|
||||
|
||||
```bash
|
||||
# Create Recovery Services vault
|
||||
az backup vault create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vault \
|
||||
--location eastus
|
||||
|
||||
# Enable backup for VM
|
||||
az backup protection enable-for-vm \
|
||||
--resource-group chatwoot-rg \
|
||||
--vault-name chatwoot-vault \
|
||||
--vm chatwoot-vm \
|
||||
--policy-name DefaultPolicy
|
||||
```
|
||||
|
||||
## Scaling and Performance
|
||||
|
||||
### VM Scale Sets
|
||||
|
||||
```bash
|
||||
# Create VM scale set
|
||||
az vmss create \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vmss \
|
||||
--image UbuntuLTS \
|
||||
--vm-sku Standard_D2s_v3 \
|
||||
--instance-count 2 \
|
||||
--vnet-name chatwoot-vnet \
|
||||
--subnet chatwoot-subnet \
|
||||
--lb chatwoot-lb \
|
||||
--backend-pool-name chatwoot-backend \
|
||||
--custom-data cloud-init.txt
|
||||
|
||||
# Configure autoscaling
|
||||
az monitor autoscale create \
|
||||
--resource-group chatwoot-rg \
|
||||
--resource chatwoot-vmss \
|
||||
--resource-type Microsoft.Compute/virtualMachineScaleSets \
|
||||
--name chatwoot-autoscale \
|
||||
--min-count 2 \
|
||||
--max-count 5 \
|
||||
--count 2
|
||||
|
||||
# Add scale-out rule
|
||||
az monitor autoscale rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--autoscale-name chatwoot-autoscale \
|
||||
--condition "Percentage CPU > 70 avg 5m" \
|
||||
--scale out 1
|
||||
|
||||
# Add scale-in rule
|
||||
az monitor autoscale rule create \
|
||||
--resource-group chatwoot-rg \
|
||||
--autoscale-name chatwoot-autoscale \
|
||||
--condition "Percentage CPU < 30 avg 5m" \
|
||||
--scale in 1
|
||||
```
|
||||
|
||||
## SSL Certificate
|
||||
|
||||
### App Service Certificate
|
||||
|
||||
```bash
|
||||
# Create App Service certificate
|
||||
az webapp config ssl upload \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-app \
|
||||
--certificate-file certificate.pfx \
|
||||
--certificate-password "certificate-password"
|
||||
|
||||
# Bind certificate to domain
|
||||
az webapp config ssl bind \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-app \
|
||||
--certificate-thumbprint <THUMBPRINT> \
|
||||
--ssl-type SNI
|
||||
```
|
||||
|
||||
### Let's Encrypt with VM
|
||||
|
||||
```bash
|
||||
# Install Certbot on VM
|
||||
sudo apt update
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtain certificate
|
||||
sudo certbot --nginx -d chatwoot.yourdomain.com
|
||||
|
||||
# Auto-renewal
|
||||
sudo crontab -e
|
||||
# Add: 0 12 * * * /usr/bin/certbot renew --quiet
|
||||
```
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
### Reserved Instances
|
||||
|
||||
```bash
|
||||
# Purchase reserved capacity for VMs
|
||||
az reservations reservation-order purchase \
|
||||
--reservation-order-id <ORDER_ID> \
|
||||
--sku Standard_D2s_v3 \
|
||||
--location eastus \
|
||||
--quantity 2 \
|
||||
--term P1Y
|
||||
```
|
||||
|
||||
### Azure Advisor
|
||||
|
||||
```bash
|
||||
# Get cost recommendations
|
||||
az advisor recommendation list \
|
||||
--category Cost \
|
||||
--resource-group chatwoot-rg
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
<Accordion title="Database connection timeout">
|
||||
Check:
|
||||
- PostgreSQL firewall rules
|
||||
- Network security group rules
|
||||
- Connection string format
|
||||
- SSL requirements for Azure Database
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Redis connection issues">
|
||||
Verify:
|
||||
- Redis access keys
|
||||
- SSL configuration (required for Azure Cache)
|
||||
- Network connectivity
|
||||
- Port 6380 (SSL) vs 6379 (non-SSL)
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Storage upload failures">
|
||||
Solutions:
|
||||
- Verify storage account access keys
|
||||
- Check container permissions
|
||||
- Ensure CORS settings if needed
|
||||
- Validate Azure Storage configuration
|
||||
</Accordion>
|
||||
|
||||
### Diagnostic Commands
|
||||
|
||||
```bash
|
||||
# Check VM status
|
||||
az vm get-instance-view \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-vm
|
||||
|
||||
# View application logs
|
||||
az webapp log tail \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-app
|
||||
|
||||
# Check database connectivity
|
||||
az postgres server show \
|
||||
--resource-group chatwoot-rg \
|
||||
--name chatwoot-postgres
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Security
|
||||
- Use Azure Key Vault for secrets management
|
||||
- Enable managed identities for Azure resources
|
||||
- Implement network security groups with least privilege
|
||||
- Enable Azure Security Center recommendations
|
||||
|
||||
### Performance
|
||||
- Use Azure CDN for static assets
|
||||
- Implement Redis caching strategies
|
||||
- Monitor with Application Insights
|
||||
- Use proximity placement groups for low latency
|
||||
|
||||
### Cost Management
|
||||
- Use Azure Cost Management for monitoring
|
||||
- Implement auto-shutdown for development VMs
|
||||
- Consider spot instances for non-critical workloads
|
||||
- Use reserved instances for predictable workloads
|
||||
|
||||
### Backup and Recovery
|
||||
- Enable automated backups for all data services
|
||||
- Test backup restoration procedures regularly
|
||||
- Implement geo-redundant storage for critical data
|
||||
- Document disaster recovery procedures
|
||||
|
||||
---
|
||||
|
||||
This Azure deployment guide provides multiple options for hosting Chatwoot on Microsoft Azure. Choose the deployment method that best fits your requirements, budget, and operational preferences.
|
||||
@@ -0,0 +1,670 @@
|
||||
---
|
||||
title: DigitalOcean Deployment
|
||||
description: Deploy Chatwoot on DigitalOcean with Droplets, App Platform, or Kubernetes
|
||||
sidebarTitle: DigitalOcean
|
||||
---
|
||||
|
||||
# DigitalOcean Deployment Guide
|
||||
|
||||
Deploy Chatwoot on DigitalOcean using Droplets, App Platform, or DigitalOcean Kubernetes for a scalable, cost-effective solution.
|
||||
|
||||
## Deployment Options
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Droplets" icon="server" href="#droplets-deployment">
|
||||
Traditional VPS deployment with full control
|
||||
</Card>
|
||||
<Card title="App Platform" icon="cloud" href="#app-platform">
|
||||
Platform-as-a-Service deployment
|
||||
</Card>
|
||||
<Card title="Kubernetes" icon="kubernetes" href="#kubernetes-deployment">
|
||||
Container orchestration with DOKS
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Droplets Deployment
|
||||
|
||||
### Quick Start with One-Click Install
|
||||
|
||||
DigitalOcean offers a one-click Chatwoot installation from the Marketplace:
|
||||
|
||||
1. **Navigate to DigitalOcean Marketplace**
|
||||
2. **Search for "Chatwoot"**
|
||||
3. **Click "Create Chatwoot Droplet"**
|
||||
4. **Configure your Droplet:**
|
||||
- **Plan**: Basic ($12/month minimum recommended)
|
||||
- **CPU options**: Regular Intel
|
||||
- **Region**: Choose closest to your users
|
||||
- **Authentication**: SSH keys (recommended)
|
||||
- **Hostname**: chatwoot-production
|
||||
|
||||
5. **Access your installation:**
|
||||
```bash
|
||||
ssh root@your-droplet-ip
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
#### Create Droplet
|
||||
|
||||
```bash
|
||||
# Using doctl CLI
|
||||
doctl compute droplet create chatwoot-prod \
|
||||
--image ubuntu-20-04-x64 \
|
||||
--size s-2vcpu-4gb \
|
||||
--region nyc3 \
|
||||
--ssh-keys your-ssh-key-id \
|
||||
--enable-monitoring \
|
||||
--enable-ipv6
|
||||
```
|
||||
|
||||
#### Install Chatwoot
|
||||
|
||||
```bash
|
||||
# SSH to droplet
|
||||
ssh root@your-droplet-ip
|
||||
|
||||
# Download and run installation script
|
||||
wget https://get.chatwoot.app/linux/install.sh
|
||||
chmod +x install.sh
|
||||
./install.sh --install
|
||||
```
|
||||
|
||||
### Database Setup
|
||||
|
||||
#### Managed PostgreSQL
|
||||
|
||||
```bash
|
||||
# Create managed database cluster
|
||||
doctl databases create chatwoot-db \
|
||||
--engine postgres \
|
||||
--version 13 \
|
||||
--size db-s-1vcpu-1gb \
|
||||
--region nyc3 \
|
||||
--num-nodes 1
|
||||
|
||||
# Create database
|
||||
doctl databases db create chatwoot-db-id chatwoot_production
|
||||
|
||||
# Create user
|
||||
doctl databases user create chatwoot-db-id chatwoot
|
||||
```
|
||||
|
||||
#### Managed Redis
|
||||
|
||||
```bash
|
||||
# Create managed Redis cluster
|
||||
doctl databases create chatwoot-redis \
|
||||
--engine redis \
|
||||
--version 6 \
|
||||
--size db-s-1vcpu-1gb \
|
||||
--region nyc3 \
|
||||
--num-nodes 1
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
Update Chatwoot configuration to use managed services:
|
||||
|
||||
```bash
|
||||
# Switch to chatwoot user
|
||||
sudo -i -u chatwoot
|
||||
cd chatwoot
|
||||
|
||||
# Edit environment file
|
||||
nano .env
|
||||
```
|
||||
|
||||
Add managed database configuration:
|
||||
|
||||
```bash
|
||||
# Database (from DigitalOcean dashboard)
|
||||
DATABASE_URL="postgresql://chatwoot:password@chatwoot-db-do-user-123456-0.b.db.ondigitalocean.com:25060/chatwoot_production?sslmode=require"
|
||||
|
||||
# Redis (from DigitalOcean dashboard)
|
||||
REDIS_URL="rediss://default:password@chatwoot-redis-do-user-123456-0.b.db.ondigitalocean.com:25061"
|
||||
|
||||
# Frontend URL
|
||||
FRONTEND_URL="https://chatwoot.yourdomain.com"
|
||||
FORCE_SSL=true
|
||||
|
||||
# Storage (DigitalOcean Spaces)
|
||||
ACTIVE_STORAGE_SERVICE="amazon"
|
||||
S3_BUCKET_NAME="your-chatwoot-space"
|
||||
AWS_ACCESS_KEY_ID="your-spaces-key"
|
||||
AWS_SECRET_ACCESS_KEY="your-spaces-secret"
|
||||
AWS_REGION="nyc3"
|
||||
S3_ENDPOINT="https://nyc3.digitaloceanspaces.com"
|
||||
```
|
||||
|
||||
### Load Balancer Setup
|
||||
|
||||
```bash
|
||||
# Create load balancer
|
||||
doctl compute load-balancer create \
|
||||
--name chatwoot-lb \
|
||||
--forwarding-rules entry_protocol:https,entry_port:443,target_protocol:http,target_port:3000,certificate_id:your-cert-id \
|
||||
--forwarding-rules entry_protocol:http,entry_port:80,target_protocol:http,target_port:3000 \
|
||||
--health-check protocol:http,port:3000,path:/api,check_interval_seconds:10,response_timeout_seconds:5,healthy_threshold:3,unhealthy_threshold:3 \
|
||||
--region nyc3 \
|
||||
--droplet-ids droplet-id-1,droplet-id-2
|
||||
```
|
||||
|
||||
## App Platform Deployment
|
||||
|
||||
### App Spec Configuration
|
||||
|
||||
Create `app.yaml`:
|
||||
|
||||
```yaml
|
||||
name: chatwoot-app
|
||||
services:
|
||||
- name: web
|
||||
source_dir: /
|
||||
github:
|
||||
repo: your-username/chatwoot-fork
|
||||
branch: main
|
||||
run_command: bundle exec rails server -b 0.0.0.0 -p $PORT
|
||||
environment_slug: ruby
|
||||
instance_count: 1
|
||||
instance_size_slug: basic-xxs
|
||||
envs:
|
||||
- key: RAILS_ENV
|
||||
value: production
|
||||
- key: DATABASE_URL
|
||||
value: ${chatwoot-db.DATABASE_URL}
|
||||
- key: REDIS_URL
|
||||
value: ${chatwoot-redis.REDIS_URL}
|
||||
- key: FRONTEND_URL
|
||||
value: ${APP_URL}
|
||||
- key: FORCE_SSL
|
||||
value: "true"
|
||||
http_port: 8080
|
||||
|
||||
- name: worker
|
||||
source_dir: /
|
||||
github:
|
||||
repo: your-username/chatwoot-fork
|
||||
branch: main
|
||||
run_command: bundle exec sidekiq -C config/sidekiq.yml
|
||||
environment_slug: ruby
|
||||
instance_count: 1
|
||||
instance_size_slug: basic-xxs
|
||||
envs:
|
||||
- key: RAILS_ENV
|
||||
value: production
|
||||
- key: DATABASE_URL
|
||||
value: ${chatwoot-db.DATABASE_URL}
|
||||
- key: REDIS_URL
|
||||
value: ${chatwoot-redis.REDIS_URL}
|
||||
|
||||
databases:
|
||||
- name: chatwoot-db
|
||||
engine: PG
|
||||
version: "13"
|
||||
size: db-s-dev-database
|
||||
|
||||
- name: chatwoot-redis
|
||||
engine: REDIS
|
||||
version: "6"
|
||||
size: db-s-dev-database
|
||||
|
||||
static_sites:
|
||||
- name: assets
|
||||
source_dir: /public
|
||||
github:
|
||||
repo: your-username/chatwoot-fork
|
||||
branch: main
|
||||
build_command: bundle exec rails assets:precompile
|
||||
```
|
||||
|
||||
### Deploy with App Platform
|
||||
|
||||
```bash
|
||||
# Deploy using doctl
|
||||
doctl apps create --spec app.yaml
|
||||
|
||||
# Or deploy via DigitalOcean Control Panel
|
||||
# 1. Go to App Platform
|
||||
# 2. Create App
|
||||
# 3. Connect your GitHub repository
|
||||
# 4. Configure build and run commands
|
||||
# 5. Add environment variables
|
||||
# 6. Deploy
|
||||
```
|
||||
|
||||
## Kubernetes Deployment
|
||||
|
||||
### Create DOKS Cluster
|
||||
|
||||
```bash
|
||||
# Create Kubernetes cluster
|
||||
doctl kubernetes cluster create chatwoot-k8s \
|
||||
--region nyc3 \
|
||||
--version 1.24.4-do.0 \
|
||||
--count 3 \
|
||||
--size s-2vcpu-4gb \
|
||||
--auto-upgrade=true \
|
||||
--maintenance-window="saturday=06:00"
|
||||
|
||||
# Get kubeconfig
|
||||
doctl kubernetes cluster kubeconfig save chatwoot-k8s
|
||||
```
|
||||
|
||||
### Helm Deployment
|
||||
|
||||
```bash
|
||||
# Add Chatwoot Helm repository
|
||||
helm repo add chatwoot https://chatwoot.github.io/charts
|
||||
helm repo update
|
||||
|
||||
# Create namespace
|
||||
kubectl create namespace chatwoot
|
||||
|
||||
# Install with DigitalOcean-specific values
|
||||
helm install chatwoot chatwoot/chatwoot \
|
||||
--namespace chatwoot \
|
||||
--set ingress.enabled=true \
|
||||
--set ingress.className=nginx \
|
||||
--set ingress.hosts[0].host=chatwoot.yourdomain.com \
|
||||
--set postgresql.enabled=false \
|
||||
--set redis.enabled=false \
|
||||
--set env.DATABASE_URL="postgresql://..." \
|
||||
--set env.REDIS_URL="redis://..."
|
||||
```
|
||||
|
||||
### DigitalOcean-Specific Values
|
||||
|
||||
Create `do-values.yaml`:
|
||||
|
||||
```yaml
|
||||
# DigitalOcean Kubernetes values
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
kubernetes.digitalocean.com/load-balancer-id: "your-lb-id"
|
||||
hosts:
|
||||
- host: chatwoot.yourdomain.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
|
||||
# Use DigitalOcean managed databases
|
||||
postgresql:
|
||||
enabled: false
|
||||
|
||||
redis:
|
||||
enabled: false
|
||||
|
||||
# DigitalOcean Spaces for storage
|
||||
env:
|
||||
ACTIVE_STORAGE_SERVICE: "amazon"
|
||||
S3_BUCKET_NAME: "your-chatwoot-space"
|
||||
AWS_ACCESS_KEY_ID: "your-spaces-key"
|
||||
AWS_SECRET_ACCESS_KEY: "your-spaces-secret"
|
||||
AWS_REGION: "nyc3"
|
||||
S3_ENDPOINT: "https://nyc3.digitaloceanspaces.com"
|
||||
|
||||
# Resource limits for DigitalOcean
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 2Gi
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 1Gi
|
||||
|
||||
# Storage class for DigitalOcean Block Storage
|
||||
persistence:
|
||||
enabled: true
|
||||
storageClass: "do-block-storage"
|
||||
size: 20Gi
|
||||
```
|
||||
|
||||
## Storage Configuration
|
||||
|
||||
### DigitalOcean Spaces
|
||||
|
||||
```bash
|
||||
# Create Spaces bucket
|
||||
doctl compute cdn create \
|
||||
--origin nyc3.digitaloceanspaces.com/your-chatwoot-space \
|
||||
--ttl 3600
|
||||
|
||||
# Configure CORS for Spaces
|
||||
# Create cors.json:
|
||||
{
|
||||
"CORSRules": [
|
||||
{
|
||||
"AllowedOrigins": ["https://chatwoot.yourdomain.com"],
|
||||
"AllowedMethods": ["GET", "PUT", "POST", "DELETE"],
|
||||
"AllowedHeaders": ["*"],
|
||||
"MaxAgeSeconds": 3000
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# Apply CORS configuration
|
||||
s3cmd setcors cors.json s3://your-chatwoot-space
|
||||
```
|
||||
|
||||
### Block Storage for Droplets
|
||||
|
||||
```bash
|
||||
# Create and attach block storage
|
||||
doctl compute volume create chatwoot-storage \
|
||||
--size 100GiB \
|
||||
--region nyc3
|
||||
|
||||
doctl compute volume-action attach chatwoot-storage \
|
||||
--droplet-id your-droplet-id
|
||||
|
||||
# Mount the volume
|
||||
sudo mkdir /mnt/chatwoot-storage
|
||||
sudo mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_chatwoot-storage /mnt/chatwoot-storage
|
||||
echo '/dev/disk/by-id/scsi-0DO_Volume_chatwoot-storage /mnt/chatwoot-storage ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
|
||||
```
|
||||
|
||||
## SSL Certificate
|
||||
|
||||
### Let's Encrypt with Certbot
|
||||
|
||||
```bash
|
||||
# Install Certbot
|
||||
sudo apt update
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtain certificate
|
||||
sudo certbot --nginx -d chatwoot.yourdomain.com
|
||||
|
||||
# Auto-renewal
|
||||
sudo crontab -e
|
||||
# Add: 0 12 * * * /usr/bin/certbot renew --quiet
|
||||
```
|
||||
|
||||
### DigitalOcean Load Balancer SSL
|
||||
|
||||
```bash
|
||||
# Upload certificate to DigitalOcean
|
||||
doctl compute certificate create \
|
||||
--name chatwoot-cert \
|
||||
--private-key-path private.key \
|
||||
--leaf-certificate-path certificate.crt \
|
||||
--certificate-chain-path ca_bundle.crt
|
||||
|
||||
# Update load balancer with certificate
|
||||
doctl compute load-balancer update your-lb-id \
|
||||
--forwarding-rules entry_protocol:https,entry_port:443,target_protocol:http,target_port:3000,certificate_id:your-cert-id
|
||||
```
|
||||
|
||||
## Monitoring and Alerting
|
||||
|
||||
### DigitalOcean Monitoring
|
||||
|
||||
```bash
|
||||
# Enable monitoring for droplets
|
||||
doctl compute droplet create chatwoot-prod \
|
||||
--enable-monitoring \
|
||||
--enable-ipv6
|
||||
|
||||
# Create alert policies
|
||||
doctl monitoring alert-policy create \
|
||||
--type v1/insights/droplet/cpu \
|
||||
--description "High CPU usage" \
|
||||
--compare GreaterThan \
|
||||
--value 80 \
|
||||
--window 5m \
|
||||
--entities droplet:your-droplet-id
|
||||
```
|
||||
|
||||
### Custom Metrics with Prometheus
|
||||
|
||||
```yaml
|
||||
# prometheus-config.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: prometheus-config
|
||||
namespace: monitoring
|
||||
data:
|
||||
prometheus.yml: |
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
scrape_configs:
|
||||
- job_name: 'chatwoot'
|
||||
static_configs:
|
||||
- targets: ['chatwoot-service:3000']
|
||||
metrics_path: /metrics
|
||||
```
|
||||
|
||||
## Backup Strategy
|
||||
|
||||
### Database Backups
|
||||
|
||||
```bash
|
||||
# Automated backups for managed databases are enabled by default
|
||||
# Manual backup
|
||||
doctl databases backups list chatwoot-db-id
|
||||
|
||||
# Restore from backup
|
||||
doctl databases backups restore chatwoot-db-id backup-id
|
||||
```
|
||||
|
||||
### Droplet Snapshots
|
||||
|
||||
```bash
|
||||
# Create snapshot
|
||||
doctl compute droplet-action snapshot your-droplet-id \
|
||||
--snapshot-name "chatwoot-backup-$(date +%Y%m%d)"
|
||||
|
||||
# Schedule automated snapshots
|
||||
doctl compute droplet-action enable-backups your-droplet-id
|
||||
```
|
||||
|
||||
### Application Data Backup
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# backup-script.sh
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
# Database backup (if using managed database)
|
||||
pg_dump $DATABASE_URL | gzip > "/tmp/chatwoot_db_$DATE.sql.gz"
|
||||
|
||||
# Upload to Spaces
|
||||
s3cmd put "/tmp/chatwoot_db_$DATE.sql.gz" s3://your-backup-space/db/
|
||||
|
||||
# File uploads backup
|
||||
s3cmd sync s3://your-chatwoot-space/ s3://your-backup-space/files/
|
||||
|
||||
# Cleanup local backup
|
||||
rm "/tmp/chatwoot_db_$DATE.sql.gz"
|
||||
```
|
||||
|
||||
## Scaling and Performance
|
||||
|
||||
### Horizontal Scaling with Load Balancer
|
||||
|
||||
```bash
|
||||
# Create additional droplets
|
||||
for i in {2..3}; do
|
||||
doctl compute droplet create chatwoot-prod-$i \
|
||||
--image ubuntu-20-04-x64 \
|
||||
--size s-2vcpu-4gb \
|
||||
--region nyc3 \
|
||||
--ssh-keys your-ssh-key-id \
|
||||
--user-data-file cloud-init.yaml
|
||||
done
|
||||
|
||||
# Add droplets to load balancer
|
||||
doctl compute load-balancer add-droplets your-lb-id \
|
||||
--droplet-ids droplet-id-2,droplet-id-3
|
||||
```
|
||||
|
||||
### Vertical Scaling
|
||||
|
||||
```bash
|
||||
# Resize droplet
|
||||
doctl compute droplet-action resize your-droplet-id \
|
||||
--size s-4vcpu-8gb \
|
||||
--resize-disk
|
||||
```
|
||||
|
||||
### Auto-scaling with Kubernetes
|
||||
|
||||
```yaml
|
||||
# hpa.yaml
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: chatwoot-hpa
|
||||
namespace: chatwoot
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: chatwoot
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 70
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
```
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
### Reserved Instances
|
||||
|
||||
```bash
|
||||
# DigitalOcean doesn't offer reserved instances
|
||||
# But you can optimize costs by:
|
||||
|
||||
# 1. Right-sizing droplets
|
||||
doctl compute size list
|
||||
|
||||
# 2. Using appropriate database sizes
|
||||
doctl databases options sizes
|
||||
|
||||
# 3. Implementing auto-scaling to scale down during low usage
|
||||
```
|
||||
|
||||
### Cost Monitoring
|
||||
|
||||
```bash
|
||||
# Check current usage and costs
|
||||
doctl account get
|
||||
|
||||
# Monitor resource usage
|
||||
doctl monitoring metrics bandwidth droplet:your-droplet-id
|
||||
doctl monitoring metrics cpu droplet:your-droplet-id
|
||||
doctl monitoring metrics memory droplet:your-droplet-id
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
<Accordion title="Droplet connection issues">
|
||||
Check:
|
||||
- Firewall rules (ufw status)
|
||||
- DigitalOcean Cloud Firewalls
|
||||
- SSH key configuration
|
||||
- Network connectivity
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Database connection problems">
|
||||
Verify:
|
||||
- Database cluster status
|
||||
- Connection string format
|
||||
- SSL requirements for managed databases
|
||||
- Firewall rules for database access
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Load balancer health check failures">
|
||||
Solutions:
|
||||
- Verify health check path (/api)
|
||||
- Check application startup time
|
||||
- Ensure proper port configuration
|
||||
- Review application logs
|
||||
</Accordion>
|
||||
|
||||
### Diagnostic Commands
|
||||
|
||||
```bash
|
||||
# Check droplet status
|
||||
doctl compute droplet get your-droplet-id
|
||||
|
||||
# View load balancer status
|
||||
doctl compute load-balancer get your-lb-id
|
||||
|
||||
# Check database status
|
||||
doctl databases get chatwoot-db-id
|
||||
|
||||
# Monitor application logs
|
||||
sudo journalctl -u chatwoot-web.1.service -f
|
||||
sudo journalctl -u chatwoot-worker.1.service -f
|
||||
```
|
||||
|
||||
### Performance Monitoring
|
||||
|
||||
```bash
|
||||
# System resources
|
||||
htop
|
||||
iostat -x 1
|
||||
free -h
|
||||
df -h
|
||||
|
||||
# Network monitoring
|
||||
iftop
|
||||
netstat -tulpn
|
||||
|
||||
# Application metrics
|
||||
curl http://localhost:3000/api
|
||||
curl http://localhost:3000/metrics
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Security
|
||||
- Enable DigitalOcean Cloud Firewalls
|
||||
- Use SSH keys instead of passwords
|
||||
- Enable automatic security updates
|
||||
- Implement fail2ban for SSH protection
|
||||
- Use managed databases for better security
|
||||
|
||||
### Performance
|
||||
- Use DigitalOcean Spaces CDN for static assets
|
||||
- Implement Redis caching
|
||||
- Monitor with DigitalOcean Monitoring
|
||||
- Use SSD-backed droplets
|
||||
- Place resources in the same region
|
||||
|
||||
### Reliability
|
||||
- Use multiple availability zones
|
||||
- Implement automated backups
|
||||
- Set up monitoring and alerting
|
||||
- Use load balancers for high availability
|
||||
- Test disaster recovery procedures
|
||||
|
||||
### Cost Management
|
||||
- Right-size your resources
|
||||
- Use managed services to reduce operational overhead
|
||||
- Implement monitoring to track usage
|
||||
- Clean up unused resources regularly
|
||||
- Consider using Kubernetes for better resource utilization
|
||||
|
||||
---
|
||||
|
||||
This DigitalOcean deployment guide provides multiple options for hosting Chatwoot on DigitalOcean's infrastructure. Choose the deployment method that best fits your technical requirements and budget constraints.
|
||||
@@ -0,0 +1,745 @@
|
||||
---
|
||||
title: Google Cloud Platform (GCP) Deployment
|
||||
description: Deploy Chatwoot on Google Cloud Platform with Compute Engine, Cloud Run, or GKE
|
||||
sidebarTitle: GCP
|
||||
---
|
||||
|
||||
# Google Cloud Platform Deployment Guide
|
||||
|
||||
Deploy Chatwoot on Google Cloud Platform using Compute Engine, Cloud Run, or Google Kubernetes Engine for a scalable, enterprise-ready solution.
|
||||
|
||||
## Deployment Options
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Compute Engine" icon="server" href="#compute-engine">
|
||||
Traditional VM deployment with full control
|
||||
</Card>
|
||||
<Card title="Cloud Run" icon="cloud" href="#cloud-run">
|
||||
Serverless container deployment
|
||||
</Card>
|
||||
<Card title="GKE" icon="kubernetes" href="#google-kubernetes-engine">
|
||||
Managed Kubernetes deployment
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Compute Engine Deployment
|
||||
|
||||
### Prerequisites
|
||||
|
||||
```bash
|
||||
# Install and configure gcloud CLI
|
||||
curl https://sdk.cloud.google.com | bash
|
||||
exec -l $SHELL
|
||||
gcloud init
|
||||
|
||||
# Set project and region
|
||||
gcloud config set project your-project-id
|
||||
gcloud config set compute/region us-central1
|
||||
gcloud config set compute/zone us-central1-a
|
||||
```
|
||||
|
||||
### Network Setup
|
||||
|
||||
```bash
|
||||
# Create VPC network
|
||||
gcloud compute networks create chatwoot-vpc --subnet-mode=custom
|
||||
|
||||
# Create subnet
|
||||
gcloud compute networks subnets create chatwoot-subnet \
|
||||
--network=chatwoot-vpc \
|
||||
--range=10.0.1.0/24 \
|
||||
--region=us-central1
|
||||
|
||||
# Create firewall rules
|
||||
gcloud compute firewall-rules create chatwoot-allow-http \
|
||||
--network=chatwoot-vpc \
|
||||
--allow=tcp:80,tcp:443,tcp:3000 \
|
||||
--source-ranges=0.0.0.0/0 \
|
||||
--target-tags=chatwoot-server
|
||||
|
||||
gcloud compute firewall-rules create chatwoot-allow-ssh \
|
||||
--network=chatwoot-vpc \
|
||||
--allow=tcp:22 \
|
||||
--source-ranges=0.0.0.0/0 \
|
||||
--target-tags=chatwoot-server
|
||||
```
|
||||
|
||||
### Database Setup
|
||||
|
||||
#### Cloud SQL PostgreSQL
|
||||
|
||||
```bash
|
||||
# Create Cloud SQL instance
|
||||
gcloud sql instances create chatwoot-db \
|
||||
--database-version=POSTGRES_13 \
|
||||
--tier=db-g1-small \
|
||||
--region=us-central1 \
|
||||
--storage-type=SSD \
|
||||
--storage-size=100GB \
|
||||
--storage-auto-increase \
|
||||
--backup-start-time=03:00 \
|
||||
--enable-bin-log \
|
||||
--maintenance-window-day=SUN \
|
||||
--maintenance-window-hour=04
|
||||
|
||||
# Create database
|
||||
gcloud sql databases create chatwoot_production --instance=chatwoot-db
|
||||
|
||||
# Create user
|
||||
gcloud sql users create chatwoot \
|
||||
--instance=chatwoot-db \
|
||||
--password=your-secure-password
|
||||
|
||||
# Get connection name
|
||||
gcloud sql instances describe chatwoot-db --format="value(connectionName)"
|
||||
```
|
||||
|
||||
#### Memorystore Redis
|
||||
|
||||
```bash
|
||||
# Create Redis instance
|
||||
gcloud redis instances create chatwoot-redis \
|
||||
--size=1 \
|
||||
--region=us-central1 \
|
||||
--redis-version=redis_6_x \
|
||||
--network=chatwoot-vpc
|
||||
```
|
||||
|
||||
### Storage Setup
|
||||
|
||||
```bash
|
||||
# Create Cloud Storage bucket
|
||||
gsutil mb -p your-project-id -c STANDARD -l us-central1 gs://your-chatwoot-bucket
|
||||
|
||||
# Set bucket permissions
|
||||
gsutil iam ch allUsers:objectViewer gs://your-chatwoot-bucket
|
||||
|
||||
# Enable CORS
|
||||
cat > cors.json << EOF
|
||||
[
|
||||
{
|
||||
"origin": ["https://chatwoot.yourdomain.com"],
|
||||
"method": ["GET", "PUT", "POST", "DELETE"],
|
||||
"responseHeader": ["Content-Type"],
|
||||
"maxAgeSeconds": 3600
|
||||
}
|
||||
]
|
||||
EOF
|
||||
|
||||
gsutil cors set cors.json gs://your-chatwoot-bucket
|
||||
```
|
||||
|
||||
### Compute Instance
|
||||
|
||||
#### Create Instance Template
|
||||
|
||||
```bash
|
||||
# Create startup script
|
||||
cat > startup-script.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
apt-get update
|
||||
apt-get install -y wget curl
|
||||
|
||||
# Download and install Chatwoot
|
||||
wget https://get.chatwoot.app/linux/install.sh
|
||||
chmod +x install.sh
|
||||
./install.sh --install
|
||||
|
||||
# Configure environment
|
||||
sudo -u chatwoot bash << 'INNER_EOF'
|
||||
cd /home/chatwoot/chatwoot
|
||||
cat > .env << 'ENV_EOF'
|
||||
RAILS_ENV=production
|
||||
NODE_ENV=production
|
||||
FRONTEND_URL=https://chatwoot.yourdomain.com
|
||||
FORCE_SSL=true
|
||||
|
||||
# Database
|
||||
DATABASE_URL=postgresql://chatwoot:password@/chatwoot_production?host=/cloudsql/your-project:us-central1:chatwoot-db
|
||||
|
||||
# Redis
|
||||
REDIS_URL=redis://10.0.0.3:6379/0
|
||||
|
||||
# Storage
|
||||
ACTIVE_STORAGE_SERVICE=google
|
||||
GCS_PROJECT=your-project-id
|
||||
GCS_BUCKET=your-chatwoot-bucket
|
||||
|
||||
# Email (using SendGrid)
|
||||
MAILER_SENDER_EMAIL=noreply@yourdomain.com
|
||||
SMTP_ADDRESS=smtp.sendgrid.net
|
||||
SMTP_PORT=587
|
||||
SMTP_USERNAME=apikey
|
||||
SMTP_PASSWORD=your-sendgrid-api-key
|
||||
SMTP_AUTHENTICATION=plain
|
||||
SMTP_ENABLE_STARTTLS_AUTO=true
|
||||
ENV_EOF
|
||||
|
||||
# Prepare database
|
||||
RAILS_ENV=production bundle exec rake db:chatwoot_prepare
|
||||
INNER_EOF
|
||||
|
||||
# Restart services
|
||||
systemctl restart chatwoot.target
|
||||
EOF
|
||||
|
||||
# Create instance template
|
||||
gcloud compute instance-templates create chatwoot-template \
|
||||
--machine-type=e2-standard-2 \
|
||||
--network-interface=network=chatwoot-vpc,subnet=chatwoot-subnet \
|
||||
--boot-disk-size=50GB \
|
||||
--boot-disk-type=pd-ssd \
|
||||
--image-family=ubuntu-2004-lts \
|
||||
--image-project=ubuntu-os-cloud \
|
||||
--tags=chatwoot-server \
|
||||
--metadata-from-file startup-script=startup-script.sh \
|
||||
--service-account=chatwoot-sa@your-project-id.iam.gserviceaccount.com \
|
||||
--scopes=https://www.googleapis.com/auth/cloud-platform
|
||||
```
|
||||
|
||||
#### Create Managed Instance Group
|
||||
|
||||
```bash
|
||||
# Create instance group
|
||||
gcloud compute instance-groups managed create chatwoot-ig \
|
||||
--template=chatwoot-template \
|
||||
--size=2 \
|
||||
--zone=us-central1-a
|
||||
|
||||
# Configure autoscaling
|
||||
gcloud compute instance-groups managed set-autoscaling chatwoot-ig \
|
||||
--max-num-replicas=5 \
|
||||
--min-num-replicas=2 \
|
||||
--target-cpu-utilization=0.7 \
|
||||
--zone=us-central1-a
|
||||
```
|
||||
|
||||
### Load Balancer
|
||||
|
||||
```bash
|
||||
# Create health check
|
||||
gcloud compute health-checks create http chatwoot-health-check \
|
||||
--port=3000 \
|
||||
--request-path=/api
|
||||
|
||||
# Create backend service
|
||||
gcloud compute backend-services create chatwoot-backend \
|
||||
--protocol=HTTP \
|
||||
--health-checks=chatwoot-health-check \
|
||||
--global
|
||||
|
||||
# Add instance group to backend service
|
||||
gcloud compute backend-services add-backend chatwoot-backend \
|
||||
--instance-group=chatwoot-ig \
|
||||
--instance-group-zone=us-central1-a \
|
||||
--global
|
||||
|
||||
# Create URL map
|
||||
gcloud compute url-maps create chatwoot-map \
|
||||
--default-service=chatwoot-backend
|
||||
|
||||
# Create SSL certificate
|
||||
gcloud compute ssl-certificates create chatwoot-ssl \
|
||||
--domains=chatwoot.yourdomain.com
|
||||
|
||||
# Create HTTPS proxy
|
||||
gcloud compute target-https-proxies create chatwoot-https-proxy \
|
||||
--url-map=chatwoot-map \
|
||||
--ssl-certificates=chatwoot-ssl
|
||||
|
||||
# Create global forwarding rule
|
||||
gcloud compute forwarding-rules create chatwoot-https-rule \
|
||||
--global \
|
||||
--target-https-proxy=chatwoot-https-proxy \
|
||||
--ports=443
|
||||
|
||||
# Create HTTP to HTTPS redirect
|
||||
gcloud compute url-maps create chatwoot-redirect \
|
||||
--default-url-redirect-response-code=301 \
|
||||
--default-url-redirect-https-redirect
|
||||
|
||||
gcloud compute target-http-proxies create chatwoot-http-proxy \
|
||||
--url-map=chatwoot-redirect
|
||||
|
||||
gcloud compute forwarding-rules create chatwoot-http-rule \
|
||||
--global \
|
||||
--target-http-proxy=chatwoot-http-proxy \
|
||||
--ports=80
|
||||
```
|
||||
|
||||
## Cloud Run Deployment
|
||||
|
||||
### Containerize Chatwoot
|
||||
|
||||
Create `Dockerfile`:
|
||||
|
||||
```dockerfile
|
||||
FROM chatwoot/chatwoot:latest
|
||||
|
||||
# Set environment variables
|
||||
ENV RAILS_ENV=production
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=8080
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Start command
|
||||
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "8080"]
|
||||
```
|
||||
|
||||
### Build and Deploy
|
||||
|
||||
```bash
|
||||
# Build container image
|
||||
gcloud builds submit --tag gcr.io/your-project-id/chatwoot
|
||||
|
||||
# Deploy to Cloud Run
|
||||
gcloud run deploy chatwoot \
|
||||
--image gcr.io/your-project-id/chatwoot \
|
||||
--platform managed \
|
||||
--region us-central1 \
|
||||
--allow-unauthenticated \
|
||||
--memory 2Gi \
|
||||
--cpu 2 \
|
||||
--max-instances 10 \
|
||||
--set-env-vars RAILS_ENV=production \
|
||||
--set-env-vars DATABASE_URL="postgresql://..." \
|
||||
--set-env-vars REDIS_URL="redis://..." \
|
||||
--set-env-vars FRONTEND_URL="https://chatwoot.yourdomain.com"
|
||||
|
||||
# Deploy worker service
|
||||
gcloud run deploy chatwoot-worker \
|
||||
--image gcr.io/your-project-id/chatwoot \
|
||||
--platform managed \
|
||||
--region us-central1 \
|
||||
--no-allow-unauthenticated \
|
||||
--memory 1Gi \
|
||||
--cpu 1 \
|
||||
--max-instances 5 \
|
||||
--command "bundle,exec,sidekiq,-C,config/sidekiq.yml" \
|
||||
--set-env-vars RAILS_ENV=production \
|
||||
--set-env-vars DATABASE_URL="postgresql://..." \
|
||||
--set-env-vars REDIS_URL="redis://..."
|
||||
```
|
||||
|
||||
### Custom Domain
|
||||
|
||||
```bash
|
||||
# Map custom domain
|
||||
gcloud run domain-mappings create \
|
||||
--service chatwoot \
|
||||
--domain chatwoot.yourdomain.com \
|
||||
--region us-central1
|
||||
```
|
||||
|
||||
## Google Kubernetes Engine (GKE)
|
||||
|
||||
### Create GKE Cluster
|
||||
|
||||
```bash
|
||||
# Create GKE cluster
|
||||
gcloud container clusters create chatwoot-cluster \
|
||||
--zone us-central1-a \
|
||||
--num-nodes 3 \
|
||||
--machine-type e2-standard-2 \
|
||||
--disk-size 50GB \
|
||||
--disk-type pd-ssd \
|
||||
--enable-autoscaling \
|
||||
--min-nodes 1 \
|
||||
--max-nodes 5 \
|
||||
--enable-autorepair \
|
||||
--enable-autoupgrade \
|
||||
--network chatwoot-vpc \
|
||||
--subnetwork chatwoot-subnet
|
||||
|
||||
# Get credentials
|
||||
gcloud container clusters get-credentials chatwoot-cluster --zone us-central1-a
|
||||
```
|
||||
|
||||
### Helm Deployment
|
||||
|
||||
```bash
|
||||
# Add Chatwoot Helm repository
|
||||
helm repo add chatwoot https://chatwoot.github.io/charts
|
||||
helm repo update
|
||||
|
||||
# Create namespace
|
||||
kubectl create namespace chatwoot
|
||||
|
||||
# Create values file for GCP
|
||||
cat > gcp-values.yaml << EOF
|
||||
# GCP-specific values
|
||||
ingress:
|
||||
enabled: true
|
||||
className: gce
|
||||
annotations:
|
||||
kubernetes.io/ingress.global-static-ip-name: "chatwoot-ip"
|
||||
networking.gke.io/managed-certificates: "chatwoot-ssl"
|
||||
kubernetes.io/ingress.allow-http: "false"
|
||||
hosts:
|
||||
- host: chatwoot.yourdomain.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
|
||||
# Use Cloud SQL and Memorystore
|
||||
postgresql:
|
||||
enabled: false
|
||||
|
||||
redis:
|
||||
enabled: false
|
||||
|
||||
env:
|
||||
DATABASE_URL: "postgresql://chatwoot:password@/chatwoot_production?host=/cloudsql/your-project:us-central1:chatwoot-db"
|
||||
REDIS_URL: "redis://10.0.0.3:6379/0"
|
||||
ACTIVE_STORAGE_SERVICE: "google"
|
||||
GCS_PROJECT: "your-project-id"
|
||||
GCS_BUCKET: "your-chatwoot-bucket"
|
||||
|
||||
# Resource limits
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 2Gi
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 1Gi
|
||||
|
||||
# Workload Identity
|
||||
serviceAccount:
|
||||
create: true
|
||||
annotations:
|
||||
iam.gke.io/gcp-service-account: chatwoot-sa@your-project-id.iam.gserviceaccount.com
|
||||
EOF
|
||||
|
||||
# Install Chatwoot
|
||||
helm install chatwoot chatwoot/chatwoot \
|
||||
--namespace chatwoot \
|
||||
--values gcp-values.yaml
|
||||
```
|
||||
|
||||
### SSL Certificate
|
||||
|
||||
```yaml
|
||||
# managed-cert.yaml
|
||||
apiVersion: networking.gke.io/v1
|
||||
kind: ManagedCertificate
|
||||
metadata:
|
||||
name: chatwoot-ssl
|
||||
namespace: chatwoot
|
||||
spec:
|
||||
domains:
|
||||
- chatwoot.yourdomain.com
|
||||
```
|
||||
|
||||
```bash
|
||||
kubectl apply -f managed-cert.yaml
|
||||
```
|
||||
|
||||
## Service Account and IAM
|
||||
|
||||
### Create Service Account
|
||||
|
||||
```bash
|
||||
# Create service account
|
||||
gcloud iam service-accounts create chatwoot-sa \
|
||||
--display-name="Chatwoot Service Account"
|
||||
|
||||
# Grant necessary permissions
|
||||
gcloud projects add-iam-policy-binding your-project-id \
|
||||
--member="serviceAccount:chatwoot-sa@your-project-id.iam.gserviceaccount.com" \
|
||||
--role="roles/cloudsql.client"
|
||||
|
||||
gcloud projects add-iam-policy-binding your-project-id \
|
||||
--member="serviceAccount:chatwoot-sa@your-project-id.iam.gserviceaccount.com" \
|
||||
--role="roles/storage.objectAdmin"
|
||||
|
||||
gcloud projects add-iam-policy-binding your-project-id \
|
||||
--member="serviceAccount:chatwoot-sa@your-project-id.iam.gserviceaccount.com" \
|
||||
--role="roles/redis.editor"
|
||||
|
||||
# Create and download key
|
||||
gcloud iam service-accounts keys create chatwoot-key.json \
|
||||
--iam-account=chatwoot-sa@your-project-id.iam.gserviceaccount.com
|
||||
```
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
### Cloud Monitoring
|
||||
|
||||
```bash
|
||||
# Enable APIs
|
||||
gcloud services enable monitoring.googleapis.com
|
||||
gcloud services enable logging.googleapis.com
|
||||
|
||||
# Create notification channel
|
||||
gcloud alpha monitoring channels create \
|
||||
--display-name="Email Alerts" \
|
||||
--type=email \
|
||||
--channel-labels=email_address=admin@yourdomain.com
|
||||
```
|
||||
|
||||
### Custom Metrics
|
||||
|
||||
```yaml
|
||||
# monitoring.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: prometheus-config
|
||||
namespace: chatwoot
|
||||
data:
|
||||
prometheus.yml: |
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
scrape_configs:
|
||||
- job_name: 'chatwoot'
|
||||
static_configs:
|
||||
- targets: ['chatwoot-service:3000']
|
||||
metrics_path: /metrics
|
||||
```
|
||||
|
||||
### Alerting Policies
|
||||
|
||||
```bash
|
||||
# Create alerting policy for high CPU
|
||||
gcloud alpha monitoring policies create \
|
||||
--policy-from-file=cpu-alert-policy.yaml
|
||||
|
||||
# cpu-alert-policy.yaml
|
||||
cat > cpu-alert-policy.yaml << EOF
|
||||
displayName: "High CPU Usage"
|
||||
conditions:
|
||||
- displayName: "CPU usage above 80%"
|
||||
conditionThreshold:
|
||||
filter: 'resource.type="gce_instance"'
|
||||
comparison: COMPARISON_GREATER_THAN
|
||||
thresholdValue: 0.8
|
||||
duration: 300s
|
||||
combiner: OR
|
||||
enabled: true
|
||||
notificationChannels:
|
||||
- projects/your-project-id/notificationChannels/CHANNEL_ID
|
||||
EOF
|
||||
```
|
||||
|
||||
## Backup and Disaster Recovery
|
||||
|
||||
### Database Backups
|
||||
|
||||
```bash
|
||||
# Cloud SQL automatic backups are enabled by default
|
||||
# Create on-demand backup
|
||||
gcloud sql backups create --instance=chatwoot-db
|
||||
|
||||
# List backups
|
||||
gcloud sql backups list --instance=chatwoot-db
|
||||
|
||||
# Restore from backup
|
||||
gcloud sql backups restore BACKUP_ID --restore-instance=chatwoot-db-restore
|
||||
```
|
||||
|
||||
### Application Backups
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# backup-script.sh
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
# Database backup
|
||||
gcloud sql export sql chatwoot-db gs://your-backup-bucket/db/chatwoot_$DATE.sql
|
||||
|
||||
# File storage backup
|
||||
gsutil -m rsync -r -d gs://your-chatwoot-bucket gs://your-backup-bucket/files/
|
||||
|
||||
# Kubernetes configuration backup
|
||||
kubectl get all -n chatwoot -o yaml > k8s-backup-$DATE.yaml
|
||||
gsutil cp k8s-backup-$DATE.yaml gs://your-backup-bucket/k8s/
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
### Network Security
|
||||
|
||||
```bash
|
||||
# Create private cluster
|
||||
gcloud container clusters create chatwoot-private \
|
||||
--enable-private-nodes \
|
||||
--master-ipv4-cidr-block 172.16.0.0/28 \
|
||||
--enable-ip-alias \
|
||||
--enable-network-policy
|
||||
|
||||
# Create firewall rules for private access
|
||||
gcloud compute firewall-rules create allow-chatwoot-private \
|
||||
--network chatwoot-vpc \
|
||||
--allow tcp:443,tcp:80 \
|
||||
--source-ranges 10.0.0.0/8
|
||||
```
|
||||
|
||||
### Secret Management
|
||||
|
||||
```bash
|
||||
# Create secrets in Secret Manager
|
||||
gcloud secrets create database-password --data-file=db-password.txt
|
||||
gcloud secrets create redis-password --data-file=redis-password.txt
|
||||
|
||||
# Grant access to service account
|
||||
gcloud secrets add-iam-policy-binding database-password \
|
||||
--member="serviceAccount:chatwoot-sa@your-project-id.iam.gserviceaccount.com" \
|
||||
--role="roles/secretmanager.secretAccessor"
|
||||
```
|
||||
|
||||
### Binary Authorization
|
||||
|
||||
```bash
|
||||
# Enable Binary Authorization
|
||||
gcloud container binauthz policy import policy.yaml
|
||||
|
||||
# policy.yaml
|
||||
cat > policy.yaml << EOF
|
||||
defaultAdmissionRule:
|
||||
requireAttestationsBy:
|
||||
- projects/your-project-id/attestors/prod-attestor
|
||||
enforcementMode: ENFORCED_BLOCK_AND_AUDIT_LOG
|
||||
globalPolicyEvaluationMode: ENABLE
|
||||
EOF
|
||||
```
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
### Preemptible Instances
|
||||
|
||||
```bash
|
||||
# Create preemptible node pool
|
||||
gcloud container node-pools create preemptible-pool \
|
||||
--cluster=chatwoot-cluster \
|
||||
--zone=us-central1-a \
|
||||
--machine-type=e2-standard-2 \
|
||||
--preemptible \
|
||||
--num-nodes=2 \
|
||||
--enable-autoscaling \
|
||||
--min-nodes=0 \
|
||||
--max-nodes=5
|
||||
```
|
||||
|
||||
### Committed Use Discounts
|
||||
|
||||
```bash
|
||||
# Purchase committed use discount
|
||||
gcloud compute commitments create chatwoot-commitment \
|
||||
--plan=12-month \
|
||||
--region=us-central1 \
|
||||
--resources=type=VCPU,amount=4 \
|
||||
--resources=type=MEMORY,amount=16
|
||||
```
|
||||
|
||||
### Resource Optimization
|
||||
|
||||
```yaml
|
||||
# resource-quota.yaml
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
metadata:
|
||||
name: chatwoot-quota
|
||||
namespace: chatwoot
|
||||
spec:
|
||||
hard:
|
||||
requests.cpu: "4"
|
||||
requests.memory: 8Gi
|
||||
limits.cpu: "8"
|
||||
limits.memory: 16Gi
|
||||
persistentvolumeclaims: "4"
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
<Accordion title="Cloud SQL connection issues">
|
||||
Check:
|
||||
- Cloud SQL Proxy configuration
|
||||
- Service account permissions
|
||||
- Network connectivity
|
||||
- SSL requirements
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="GKE pod startup failures">
|
||||
Verify:
|
||||
- Resource quotas and limits
|
||||
- Image pull permissions
|
||||
- Service account configuration
|
||||
- Network policies
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Load balancer health check failures">
|
||||
Solutions:
|
||||
- Verify health check path (/api)
|
||||
- Check firewall rules
|
||||
- Ensure proper backend configuration
|
||||
- Review application startup time
|
||||
</Accordion>
|
||||
|
||||
### Diagnostic Commands
|
||||
|
||||
```bash
|
||||
# Check Compute Engine instances
|
||||
gcloud compute instances list
|
||||
|
||||
# View Cloud Run services
|
||||
gcloud run services list
|
||||
|
||||
# Check GKE cluster status
|
||||
gcloud container clusters describe chatwoot-cluster --zone us-central1-a
|
||||
|
||||
# View logs
|
||||
gcloud logging read "resource.type=gce_instance" --limit 50
|
||||
gcloud logging read "resource.type=cloud_run_revision" --limit 50
|
||||
|
||||
# Check Cloud SQL status
|
||||
gcloud sql instances describe chatwoot-db
|
||||
```
|
||||
|
||||
### Performance Monitoring
|
||||
|
||||
```bash
|
||||
# View metrics
|
||||
gcloud monitoring metrics list --filter="metric.type:compute"
|
||||
|
||||
# Create dashboard
|
||||
gcloud monitoring dashboards create --config-from-file=dashboard.json
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Security
|
||||
- Use private GKE clusters
|
||||
- Enable Workload Identity
|
||||
- Implement Binary Authorization
|
||||
- Use Secret Manager for sensitive data
|
||||
- Enable audit logging
|
||||
|
||||
### Performance
|
||||
- Use Cloud CDN for static assets
|
||||
- Implement Cloud Memorystore for caching
|
||||
- Use SSD persistent disks
|
||||
- Enable HTTP/2 and gRPC
|
||||
- Optimize container images
|
||||
|
||||
### Reliability
|
||||
- Deploy across multiple zones
|
||||
- Use managed services (Cloud SQL, Memorystore)
|
||||
- Implement proper health checks
|
||||
- Set up monitoring and alerting
|
||||
- Test disaster recovery procedures
|
||||
|
||||
### Cost Management
|
||||
- Use preemptible instances for non-critical workloads
|
||||
- Implement resource quotas
|
||||
- Purchase committed use discounts
|
||||
- Monitor usage with Cloud Billing
|
||||
- Use Cloud Functions for event-driven tasks
|
||||
|
||||
---
|
||||
|
||||
This GCP deployment guide provides comprehensive options for hosting Chatwoot on Google Cloud Platform. Choose the deployment method that best aligns with your scalability, security, and operational requirements.
|
||||
@@ -0,0 +1,505 @@
|
||||
---
|
||||
title: Heroku Deployment
|
||||
description: Deploy Chatwoot on Heroku with one-click deployment and managed services
|
||||
sidebarTitle: Heroku
|
||||
---
|
||||
|
||||
# Heroku Deployment Guide
|
||||
|
||||
Deploy Chatwoot on Heroku using the one-click deployment option for a quick and managed hosting solution. This guide covers deployment, configuration, and maintenance on Heroku's platform.
|
||||
|
||||
<Note>
|
||||
Heroku has discontinued free dynos, postgres and redis. [Chatwoot will use basic/mini plans](https://blog.heroku.com/new-low-cost-plans) for all new Heroku deployments going forward.
|
||||
</Note>
|
||||
|
||||
## Quick Deployment
|
||||
|
||||
### One-Click Deploy
|
||||
|
||||
The fastest way to get Chatwoot running on Heroku is using the one-click deploy button:
|
||||
|
||||
<Card title="Deploy to Heroku" icon="heroku" href="https://heroku.com/deploy?template=https://github.com/chatwoot/chatwoot">
|
||||
Click here to deploy Chatwoot to Heroku with one click
|
||||
</Card>
|
||||
|
||||
### Deployment Steps
|
||||
|
||||
1. **Click the Deploy Button**: Use the one-click deploy button above
|
||||
2. **Configure App Settings**:
|
||||
- Choose an app name (or let Heroku generate one)
|
||||
- Select your region (US or Europe)
|
||||
- Review the default configuration
|
||||
|
||||
3. **Deploy the Application**: Click "Deploy app" and wait for the build to complete
|
||||
|
||||
4. **Enable Worker Dynos**:
|
||||
- Go to the **Resources** tab in your Heroku app dashboard
|
||||
- Ensure the **worker** dynos are turned on
|
||||
- This is crucial for background job processing
|
||||
|
||||
5. **Configure Environment Variables**:
|
||||
- Go to **Settings** tab in Heroku app dashboard
|
||||
- Click **Reveal Config Vars**
|
||||
- Configure additional variables as needed
|
||||
|
||||
6. **Access Your Installation**: Navigate to `yourapp.herokuapp.com`
|
||||
|
||||
## Configuration
|
||||
|
||||
### Required Environment Variables
|
||||
|
||||
Heroku automatically sets up basic configuration, but you'll need to configure additional variables:
|
||||
|
||||
#### Email Configuration
|
||||
|
||||
```bash
|
||||
# SMTP Settings (required for notifications)
|
||||
MAILER_SENDER_EMAIL=noreply@yourdomain.com
|
||||
SMTP_ADDRESS=smtp.sendgrid.net
|
||||
SMTP_PORT=587
|
||||
SMTP_USERNAME=apikey
|
||||
SMTP_PASSWORD=your-sendgrid-api-key
|
||||
SMTP_AUTHENTICATION=plain
|
||||
SMTP_ENABLE_STARTTLS_AUTO=true
|
||||
```
|
||||
|
||||
#### File Storage Configuration
|
||||
|
||||
<Warning>
|
||||
Heroku has an "ephemeral" hard disk. Files uploaded to Chatwoot will not persist after application restarts. You must configure cloud storage.
|
||||
</Warning>
|
||||
|
||||
**Amazon S3 Configuration:**
|
||||
|
||||
```bash
|
||||
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 Configuration:**
|
||||
|
||||
```bash
|
||||
ACTIVE_STORAGE_SERVICE=google
|
||||
GCS_PROJECT=your-project-id
|
||||
GCS_BUCKET=your-chatwoot-bucket
|
||||
GOOGLE_APPLICATION_CREDENTIALS={"type":"service_account",...}
|
||||
```
|
||||
|
||||
#### Frontend URL
|
||||
|
||||
```bash
|
||||
FRONTEND_URL=https://yourapp.herokuapp.com
|
||||
FORCE_SSL=true
|
||||
```
|
||||
|
||||
### Setting Environment Variables
|
||||
|
||||
#### Via Heroku Dashboard
|
||||
|
||||
1. Go to your app's **Settings** tab
|
||||
2. Click **Reveal Config Vars**
|
||||
3. Add each variable name and value
|
||||
4. Click **Add** for each variable
|
||||
|
||||
#### Via Heroku CLI
|
||||
|
||||
```bash
|
||||
# Install Heroku CLI
|
||||
npm install -g heroku
|
||||
|
||||
# Login to Heroku
|
||||
heroku login
|
||||
|
||||
# Set environment variables
|
||||
heroku config:set MAILER_SENDER_EMAIL=noreply@yourdomain.com -a your-app-name
|
||||
heroku config:set SMTP_ADDRESS=smtp.sendgrid.net -a your-app-name
|
||||
heroku config:set SMTP_PORT=587 -a your-app-name
|
||||
|
||||
# Set storage configuration
|
||||
heroku config:set ACTIVE_STORAGE_SERVICE=amazon -a your-app-name
|
||||
heroku config:set S3_BUCKET_NAME=your-bucket -a your-app-name
|
||||
heroku config:set AWS_ACCESS_KEY_ID=your-key -a your-app-name
|
||||
heroku config:set AWS_SECRET_ACCESS_KEY=your-secret -a your-app-name
|
||||
```
|
||||
|
||||
## Add-ons and Services
|
||||
|
||||
### Database (PostgreSQL)
|
||||
|
||||
Heroku automatically provisions a PostgreSQL database:
|
||||
|
||||
```bash
|
||||
# Check database info
|
||||
heroku pg:info -a your-app-name
|
||||
|
||||
# Access database console
|
||||
heroku pg:psql -a your-app-name
|
||||
|
||||
# Create database backup
|
||||
heroku pg:backups:capture -a your-app-name
|
||||
|
||||
# Download backup
|
||||
heroku pg:backups:download -a your-app-name
|
||||
```
|
||||
|
||||
### Redis
|
||||
|
||||
Heroku automatically provisions Redis for caching and background jobs:
|
||||
|
||||
```bash
|
||||
# Check Redis info
|
||||
heroku redis:info -a your-app-name
|
||||
|
||||
# Access Redis CLI
|
||||
heroku redis:cli -a your-app-name
|
||||
|
||||
# Monitor Redis
|
||||
heroku redis:monitor -a your-app-name
|
||||
```
|
||||
|
||||
### Email Service (SendGrid)
|
||||
|
||||
Add SendGrid for email delivery:
|
||||
|
||||
```bash
|
||||
# Add SendGrid add-on
|
||||
heroku addons:create sendgrid:starter -a your-app-name
|
||||
|
||||
# Get SendGrid credentials
|
||||
heroku config:get SENDGRID_USERNAME -a your-app-name
|
||||
heroku config:get SENDGRID_PASSWORD -a your-app-name
|
||||
```
|
||||
|
||||
## Updating Your Deployment
|
||||
|
||||
### Method 1: GitHub Integration (Recommended)
|
||||
|
||||
1. **Connect GitHub Repository**:
|
||||
- Go to the **Deploy** tab in your Heroku app dashboard
|
||||
- Choose **GitHub** as the deployment method
|
||||
- Connect the `chatwoot/chatwoot` repository
|
||||
|
||||
2. **Enable Automatic Deploys** (Optional):
|
||||
- Enable automatic deploys from the `master` branch
|
||||
- This will automatically deploy when new releases are available
|
||||
|
||||
3. **Manual Deploy**:
|
||||
- Go to **Manual deploy** section
|
||||
- Choose `master` branch
|
||||
- Click **Deploy Branch**
|
||||
|
||||
### Method 2: Heroku CLI
|
||||
|
||||
```bash
|
||||
# Clone the Chatwoot repository
|
||||
git clone https://github.com/chatwoot/chatwoot.git
|
||||
cd chatwoot
|
||||
|
||||
# Add Heroku remote
|
||||
heroku git:remote -a your-app-name
|
||||
|
||||
# Deploy latest version
|
||||
git push heroku master
|
||||
```
|
||||
|
||||
### Method 3: Docker Deployment
|
||||
|
||||
```bash
|
||||
# Login to Heroku Container Registry
|
||||
heroku container:login
|
||||
|
||||
# Build and push Docker image
|
||||
heroku container:push web -a your-app-name
|
||||
|
||||
# Release the image
|
||||
heroku container:release web -a your-app-name
|
||||
```
|
||||
|
||||
## Scaling and Performance
|
||||
|
||||
### Dyno Management
|
||||
|
||||
```bash
|
||||
# Scale web dynos
|
||||
heroku ps:scale web=2 -a your-app-name
|
||||
|
||||
# Scale worker dynos
|
||||
heroku ps:scale worker=1 -a your-app-name
|
||||
|
||||
# Check dyno status
|
||||
heroku ps -a your-app-name
|
||||
```
|
||||
|
||||
### Performance Monitoring
|
||||
|
||||
```bash
|
||||
# View application metrics
|
||||
heroku logs --tail -a your-app-name
|
||||
|
||||
# Monitor dyno performance
|
||||
heroku ps:exec -a your-app-name
|
||||
|
||||
# Check memory usage
|
||||
heroku logs --source app --tail -a your-app-name | grep "Memory usage"
|
||||
```
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
### Application Logs
|
||||
|
||||
```bash
|
||||
# View recent logs
|
||||
heroku logs -a your-app-name
|
||||
|
||||
# Tail logs in real-time
|
||||
heroku logs --tail -a your-app-name
|
||||
|
||||
# Filter logs by source
|
||||
heroku logs --source app -a your-app-name
|
||||
heroku logs --source heroku -a your-app-name
|
||||
```
|
||||
|
||||
### Add Monitoring Services
|
||||
|
||||
#### Papertrail (Log Management)
|
||||
|
||||
```bash
|
||||
# Add Papertrail
|
||||
heroku addons:create papertrail:choklad -a your-app-name
|
||||
|
||||
# View logs in Papertrail
|
||||
heroku addons:open papertrail -a your-app-name
|
||||
```
|
||||
|
||||
#### New Relic (Application Monitoring)
|
||||
|
||||
```bash
|
||||
# Add New Relic
|
||||
heroku addons:create newrelic:wayne -a your-app-name
|
||||
|
||||
# Configure New Relic
|
||||
heroku config:set NEW_RELIC_APP_NAME="Chatwoot Production" -a your-app-name
|
||||
|
||||
# Open New Relic dashboard
|
||||
heroku addons:open newrelic -a your-app-name
|
||||
```
|
||||
|
||||
## Security Configuration
|
||||
|
||||
### SSL/TLS
|
||||
|
||||
Heroku automatically provides SSL certificates for custom domains:
|
||||
|
||||
```bash
|
||||
# Add custom domain
|
||||
heroku domains:add chatwoot.yourdomain.com -a your-app-name
|
||||
|
||||
# Check SSL certificate status
|
||||
heroku certs -a your-app-name
|
||||
|
||||
# Enable Automated Certificate Management
|
||||
heroku certs:auto:enable -a your-app-name
|
||||
```
|
||||
|
||||
### Environment Security
|
||||
|
||||
```bash
|
||||
# Rotate database credentials
|
||||
heroku pg:credentials:rotate -a your-app-name
|
||||
|
||||
# Rotate Redis credentials
|
||||
heroku redis:credentials:rotate -a your-app-name
|
||||
|
||||
# Review security settings
|
||||
heroku config -a your-app-name
|
||||
```
|
||||
|
||||
## Backup and Recovery
|
||||
|
||||
### Database Backups
|
||||
|
||||
```bash
|
||||
# Schedule automatic backups
|
||||
heroku pg:backups:schedule DATABASE_URL --at '02:00 America/Los_Angeles' -a your-app-name
|
||||
|
||||
# Create manual backup
|
||||
heroku pg:backups:capture -a your-app-name
|
||||
|
||||
# List all backups
|
||||
heroku pg:backups -a your-app-name
|
||||
|
||||
# Restore from backup
|
||||
heroku pg:backups:restore b001 DATABASE_URL -a your-app-name
|
||||
```
|
||||
|
||||
### File Storage Backups
|
||||
|
||||
Since Heroku has ephemeral storage, ensure your cloud storage has backup policies:
|
||||
|
||||
**For S3:**
|
||||
```bash
|
||||
# Enable versioning on S3 bucket
|
||||
aws s3api put-bucket-versioning \
|
||||
--bucket your-chatwoot-bucket \
|
||||
--versioning-configuration Status=Enabled
|
||||
|
||||
# Set up lifecycle policy for old versions
|
||||
aws s3api put-bucket-lifecycle-configuration \
|
||||
--bucket your-chatwoot-bucket \
|
||||
--lifecycle-configuration file://lifecycle.json
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
<Accordion title="Application not starting">
|
||||
**Symptoms**: App crashes on startup, H10 errors
|
||||
|
||||
**Solutions**:
|
||||
- Check that worker dynos are enabled in Resources tab
|
||||
- Verify all required environment variables are set
|
||||
- Check application logs: `heroku logs --tail -a your-app-name`
|
||||
- Ensure database migrations have run: `heroku run rails db:migrate -a your-app-name`
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="File uploads not working">
|
||||
**Symptoms**: Files upload but disappear after app restart
|
||||
|
||||
**Solutions**:
|
||||
- Configure cloud storage (S3, GCS, etc.)
|
||||
- Verify storage credentials are correct
|
||||
- Check CORS settings on your storage bucket
|
||||
- Test storage configuration: `heroku run rails console -a your-app-name`
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Email notifications not sending">
|
||||
**Symptoms**: Users not receiving email notifications
|
||||
|
||||
**Solutions**:
|
||||
- Verify SMTP configuration in config vars
|
||||
- Check SendGrid add-on status
|
||||
- Test email configuration: `heroku run rails console -a your-app-name`
|
||||
- Review email logs in SendGrid dashboard
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Build version shows as unknown">
|
||||
**Symptoms**: Settings page shows "unknown" build version
|
||||
|
||||
**Solution**:
|
||||
Enable runtime dyno metadata:
|
||||
```bash
|
||||
heroku labs:enable runtime-dyno-metadata -a your-app-name
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
### Performance Issues
|
||||
|
||||
<Accordion title="Slow response times">
|
||||
**Solutions**:
|
||||
- Scale up web dynos: `heroku ps:scale web=2 -a your-app-name`
|
||||
- Upgrade to higher performance dynos
|
||||
- Monitor database performance with `heroku pg:diagnose -a your-app-name`
|
||||
- Check Redis performance with `heroku redis:info -a your-app-name`
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Background jobs not processing">
|
||||
**Solutions**:
|
||||
- Ensure worker dynos are running: `heroku ps -a your-app-name`
|
||||
- Scale worker dynos if needed: `heroku ps:scale worker=1 -a your-app-name`
|
||||
- Check Sidekiq logs: `heroku logs --source app --tail -a your-app-name | grep sidekiq`
|
||||
</Accordion>
|
||||
|
||||
### Diagnostic Commands
|
||||
|
||||
```bash
|
||||
# Check app status
|
||||
heroku ps -a your-app-name
|
||||
|
||||
# View configuration
|
||||
heroku config -a your-app-name
|
||||
|
||||
# Check add-ons
|
||||
heroku addons -a your-app-name
|
||||
|
||||
# Run Rails console
|
||||
heroku run rails console -a your-app-name
|
||||
|
||||
# Run database migrations
|
||||
heroku run rails db:migrate -a your-app-name
|
||||
|
||||
# Check database status
|
||||
heroku pg:info -a your-app-name
|
||||
|
||||
# Check Redis status
|
||||
heroku redis:info -a your-app-name
|
||||
```
|
||||
|
||||
## Known Limitations
|
||||
|
||||
### Platform Limitations
|
||||
|
||||
1. **Ephemeral File System**: Files uploaded to local storage will be lost on dyno restart
|
||||
2. **Dyno Sleep**: Free tier dynos sleep after 30 minutes of inactivity (upgrade to paid tier to avoid)
|
||||
3. **Request Timeout**: Heroku has a 30-second request timeout limit
|
||||
4. **Memory Limits**: Dynos have memory limits based on the plan selected
|
||||
|
||||
### Workarounds
|
||||
|
||||
1. **File Storage**: Use cloud storage (S3, GCS) instead of local storage
|
||||
2. **Dyno Sleep**: Upgrade to paid dynos or use external monitoring to keep app awake
|
||||
3. **Long Requests**: Implement background job processing for long-running tasks
|
||||
4. **Memory Usage**: Monitor and optimize application memory usage
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
### Dyno Sizing
|
||||
|
||||
```bash
|
||||
# Check current dyno usage
|
||||
heroku ps -a your-app-name
|
||||
|
||||
# Optimize dyno allocation
|
||||
heroku ps:scale web=1:standard-1x worker=1:standard-1x -a your-app-name
|
||||
```
|
||||
|
||||
### Add-on Optimization
|
||||
|
||||
- Use appropriate add-on tiers based on usage
|
||||
- Monitor add-on usage and costs in Heroku dashboard
|
||||
- Consider consolidating services where possible
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Security
|
||||
- Use environment variables for all sensitive configuration
|
||||
- Enable Automated Certificate Management for SSL
|
||||
- Regularly rotate database and Redis credentials
|
||||
- Monitor access logs and set up alerts
|
||||
|
||||
### Performance
|
||||
- Use appropriate dyno types for your workload
|
||||
- Monitor application performance with New Relic or similar
|
||||
- Implement caching strategies
|
||||
- Optimize database queries
|
||||
|
||||
### Reliability
|
||||
- Set up automatic database backups
|
||||
- Monitor application health with external services
|
||||
- Implement proper error handling and logging
|
||||
- Use multiple dynos for high availability
|
||||
|
||||
### Cost Management
|
||||
- Monitor dyno usage and scale appropriately
|
||||
- Use scheduler add-on for periodic tasks instead of always-on workers
|
||||
- Review and optimize add-on usage regularly
|
||||
- Consider reserved capacity for predictable workloads
|
||||
|
||||
---
|
||||
|
||||
This Heroku deployment guide provides a complete solution for hosting Chatwoot on Heroku's platform. The managed infrastructure and add-on ecosystem make it an excellent choice for teams who want to focus on using Chatwoot rather than managing infrastructure.
|
||||
|
||||
For more information, visit the [official Chatwoot Heroku documentation](https://www.chatwoot.com/docs/self-hosted/deployment/heroku).
|
||||
Reference in New Issue
Block a user