Skip to content

Deployment Guide

This guide covers production deployment of SirrChat server.

System Requirements

Hardware Requirements

yaml
Minimum Configuration:
  CPU: 2 cores
  RAM: 2GB
  Storage: 20GB SSD
  Network: 100Mbps

Recommended Configuration:
  CPU: 4 cores
  RAM: 4GB
  Storage: 100GB SSD
  Network: 1Gbps

Software Requirements

yaml
Operating System:
  - Ubuntu 20.04+
  - Debian 11+
  - CentOS 8+
  - macOS 12+

Dependencies:
  - Go 1.24+ (for building from source)
  - Git
  - Make

Port Requirements

PortServiceDescription
25SMTPMail reception (optional)
587SubmissionMail submission
465SMTPSEncrypted mail submission
993IMAPSEncrypted IMAP
143IMAPIMAP (optional)
8825SMTP AltAlternative SMTP port

Quick Deployment

One-Click Deployment Script

Use the automated script for quick deployment:

bash
# Download and execute deployment script
curl -sSL https://raw.githubusercontent.com/mail-chat-chain/mailchatd/main/start.sh | bash

# Or download first
wget https://raw.githubusercontent.com/mail-chat-chain/mailchatd/main/start.sh
chmod +x start.sh
sudo ./start.sh

The script will automatically:

  1. Detect system architecture and download the correct binary
  2. Initialize configuration directory
  3. Configure DNS and TLS certificates (supports 15 DNS providers)
  4. Create and start systemd service

Manual Deployment

1. System Preparation

bash
# Update system
sudo apt update && sudo apt upgrade -y

# Install dependencies
sudo apt install -y build-essential git curl wget

# Create working directory
export SIRRCHAT_HOME="${SIRRCHAT_HOME:-$HOME/.sirrchatd}"
mkdir -p $SIRRCHAT_HOME

2. Download Binary

bash
# Auto-detect system architecture
get_system_arch() {
    local os=$(uname -s | tr '[:upper:]' '[:lower:]')
    local arch=$(uname -m)

    case "$arch" in
        x86_64|amd64) arch="amd64" ;;
        aarch64|arm64) arch="arm64" ;;
        *) arch="amd64" ;;
    esac

    echo "${os}-${arch}"
}

SYSTEM_ARCH=$(get_system_arch)
VERSION="v0.3.1"

# Download corresponding version
wget https://download.sirrchat.org/sirrchatd-${SYSTEM_ARCH}-${VERSION}
sudo mv sirrchatd-${SYSTEM_ARCH}-${VERSION} /usr/local/bin/sirrchatd
sudo chmod +x /usr/local/bin/sirrchatd

# Verify installation
sirrchatd --help

3. Build from Source (Optional)

bash
# Clone repository
git clone https://github.com/mail-chat-chain/mailchatd.git
cd sirrchatd

# Build
make build

# Install
sudo cp build/sirrchatd /usr/local/bin/

Configuration

Basic Configuration

Create $SIRRCHAT_HOME/sirrchatd.conf:

conf
# Domain configuration
$(hostname) = mx1.example.com
$(primary_domain) = example.com
$(local_domains) = $(primary_domain)

# TLS certificate configuration
tls {
    loader acme {
        hostname $(hostname)
        email postmaster@$(hostname)
        agreed
        challenge dns-01
        dns cloudflare {
            api_token YOUR_CLOUDFLARE_API_TOKEN
        }
    }
}

# Storage configuration
storage.imapsql local_mailboxes {
    driver sqlite3
    dsn $SIRRCHAT_HOME/imapsql.db
}

# Authentication configuration
auth.pass_table local_auth {
    table file $SIRRCHAT_HOME/users
}

# SMTP service
smtp tcp://0.0.0.0:8825 {
    hostname $(hostname)

    limits {
        all rate 20 1s
        all concurrency 10
    }

    dmarc yes

    check {
        require_mx_record
        dkim
        spf
    }

    source $(local_domains) {
        deliver_to &local_mailboxes
    }
}

# Submission service
submission tls://0.0.0.0:465 tcp://0.0.0.0:587 {
    hostname $(hostname)
    auth &local_auth

    source $(local_domains) {
        default_destination {
            modify {
                dkim $(primary_domain) $(local_domains) default
            }
            deliver_to &remote_queue
        }
    }
}

# IMAP service
imap tls://0.0.0.0:993 tcp://0.0.0.0:143 {
    auth &local_auth
    storage &local_mailboxes
}

DNS Provider Configuration

Supported DNS providers and their configuration:

Cloudflare

conf
dns cloudflare {
    api_token YOUR_API_TOKEN
}

Amazon Route53

conf
dns route53 {
    access_key_id YOUR_ACCESS_KEY
    secret_access_key YOUR_SECRET_KEY
}

DigitalOcean

conf
dns digitalocean {
    api_token YOUR_API_TOKEN
}

Google Cloud DNS

conf
dns googleclouddns {
    service_account_json /path/to/service-account.json
}

Service Management

Systemd Service Configuration

Create Mail Service

bash
sudo tee /etc/systemd/system/sirrchatd-mail.service > /dev/null <<EOF
[Unit]
Description=SirrChat Mail Server
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=root
Environment="SIRRCHAT_HOME=/root/.sirrchatd"
ExecStart=/usr/local/bin/sirrchatd run
Restart=always
RestartSec=3
LimitNOFILE=65535
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
EOF

Start and Manage Service

bash
# Reload systemd configuration
sudo systemctl daemon-reload

# Start service
sudo systemctl start sirrchatd-mail

# Enable auto-start on boot
sudo systemctl enable sirrchatd-mail

# Check service status
sudo systemctl status sirrchatd-mail

# View logs
sudo journalctl -u sirrchatd-mail -f

# Restart service
sudo systemctl restart sirrchatd-mail

Monitoring and Maintenance

Log Viewing

bash
# View real-time logs
sudo journalctl -u sirrchatd-mail -f

# View recent error logs
sudo journalctl -u sirrchatd-mail -p err -n 100

# View today's logs
sudo journalctl -u sirrchatd-mail --since today

Health Check Script

Create ~/check_sirrchat_health.sh:

bash
#!/bin/bash

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

echo "=== SirrChat Health Check ==="
echo "Time: $(date)"
echo "=============================="

# Check process status
if pgrep -x sirrchatd > /dev/null; then
    echo -e "${GREEN}✓${NC} Process is running"
else
    echo -e "${RED}✗${NC} Process is NOT running"
    exit 1
fi

# Check ports
for port in 587 993 8825; do
    if netstat -tlnp 2>/dev/null | grep -q ":$port "; then
        echo -e "${GREEN}✓${NC} Port $port is listening"
    else
        echo -e "${RED}✗${NC} Port $port is NOT listening"
    fi
done

# Check disk space
DISK_USAGE=$(df -h $SIRRCHAT_HOME | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$DISK_USAGE" -lt 80 ]; then
    echo -e "${GREEN}✓${NC} Disk usage: ${DISK_USAGE}%"
else
    echo -e "${RED}⚠${NC} Disk usage high: ${DISK_USAGE}%"
fi

echo "=============================="

Troubleshooting

Common Issues

1. Service won't start

bash
# Check configuration file syntax
sirrchatd run --config $SIRRCHAT_HOME/sirrchatd.conf

# View detailed errors
sudo journalctl -u sirrchatd-mail -n 50

2. TLS certificate issues

bash
# Check DNS configuration
sirrchatd dns check

# Manually test DNS challenge
sirrchatd dns export

3. Cannot send/receive emails

bash
# Check if ports are open
netstat -tlnp | grep -E '25|587|993'

# Check firewall
sudo ufw status

Security Best Practices

Firewall Configuration

bash
# Basic firewall rules
sudo ufw default deny incoming
sudo ufw default allow outgoing

# SSH access
sudo ufw allow 22/tcp

# Mail service ports
sudo ufw allow 587/tcp comment 'Submission'
sudo ufw allow 993/tcp comment 'IMAPS'
sudo ufw allow 8825/tcp comment 'SMTP Alt'

# Enable firewall
sudo ufw enable

Security Checklist

  • [ ] Firewall rules properly configured
  • [ ] SSH using key authentication
  • [ ] TLS certificates configured and auto-renewing
  • [ ] System automatic security updates enabled
  • [ ] Log rotation configured
  • [ ] Regular backups implemented

Backup Recommendations

bash
# Backup configuration and data
BACKUP_DIR="/backup/sirrchatd/$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR

# Backup configuration
cp $SIRRCHAT_HOME/sirrchatd.conf $BACKUP_DIR/

# Backup database
cp $SIRRCHAT_HOME/*.db $BACKUP_DIR/

# Keep backups for last 7 days
find /backup/sirrchatd -type d -mtime +7 -exec rm -rf {} +

Production Recommendations

Database Selection

  • Development: SQLite (simple, no extra setup)
  • Production: PostgreSQL (best performance and features)
  • Alternative: MySQL 8.0+ (good performance)

Storage Backend

  • Development: Filesystem storage
  • Production: S3-compatible storage (scalable, durable)

Monitoring

  • Enable Prometheus metrics endpoint
  • Set up alerting for disk space, memory usage
  • Monitor email queue size
  • Track authentication failures

Last updated: December 2025

Released under the GPL 3.0 License.