IF
IndexFlowing
/ Docs
🌐 切换中文文档 GitHub ↗

Production Deployment

This guide provides instructions for deploying the IndexFlow Documentation (docs.indexflowing.com), the IndexFlow Cloud Web Service (www.indexflowing.com), and the IndexFlow Core Engine (IndexFlow-core) to a production VPS.


Architecture Overview

                                Internet
                                   │
                    ┌──────────────┴──────────────┐
                    │     Cloudflare / Nginx      │
                    └──────────────┬──────────────┘
                                   │
         ┌─────────────────────────┼─────────────────────────┐
         │                         │                         │
         ▼                         ▼                         ▼
┌──────────────────┐     ┌──────────────────┐     ┌──────────────────┐
│ Documentation    │     │ Commercial Web   │     │ Open-Core Engine │
│ docs.indexflowing│     │ www.indexflowing │     │ Private / VPS    │
│ (Static mdBook)  │     │ (Axum Port 8000) │     │ (Axum Port 8080) │
└──────────────────┘     └──────────────────┘     └──────────────────┘

1. Deploying the Documentation Website (docs.indexflowing.com)

The documentation is built with mdBook and served as a static website.

Step 1: Install mdBook on the Build Server

cargo install mdbook

Step 2: Compile the Documentation

From the IndexFlow-cloud/docs directory:

cd IndexFlow-cloud/docs
mdbook build

This generates compiled HTML assets in IndexFlow-cloud/docs/book/.

Step 3: Nginx Virtual Host Configuration

Create /etc/nginx/sites-available/docs.indexflowing.com:

server {
    listen 80;
    listen [::]:80;
    server_name docs.indexflowing.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name docs.indexflowing.com;

    ssl_certificate /etc/letsencrypt/live/docs.indexflowing.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/docs.indexflowing.com/privkey.pem;

    root /var/www/indexflow-docs/book;
    index index.html;

    # Gzip static asset compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    location / {
        try_files $uri $uri/ =404;
        expires 1h;
        add_header Cache-Control "public, no-transform";
    }
}

2. Deploying IndexFlow-core on a VPS

Step 1: Build the Release Binary

cd IndexFlow-core
cargo build --release
sudo cp target/release/indexflow-core /usr/local/bin/indexflow-core

Step 2: Configure System User & Storage

sudo useradd -r -s /bin/false -d /var/lib/indexflow indexflow
sudo mkdir -p /var/lib/indexflow
sudo mkdir -p /etc/indexflow
sudo chown -R indexflow:indexflow /var/lib/indexflow

Step 3: Production Environment File

Create /etc/indexflow/indexflow.env:

SERVER_HOST=127.0.0.1
SERVER_PORT=8080
DATABASE_URL=sqlite:/var/lib/indexflow/indexflow.db?mode=rwc
DB_MAX_CONNECTIONS=10
WORKER_POLL_INTERVAL_SECS=2
SUBMIT_WORKER_INTERVAL_SECS=5
SUBMIT_WORKER_BATCH=10
JWT_SECRET=generate-a-strong-64-character-random-key-here
DRY_RUN=false
RUST_LOG=indexflow_core=info,tower_http=info

Step 4: Systemd Service Unit

Create /etc/systemd/system/indexflow.service:

[Unit]
Description=IndexFlow Open-Core Search Indexing Infrastructure
After=network.target

[Service]
Type=simple
User=indexflow
Group=indexflow
EnvironmentFile=/etc/indexflow/indexflow.env
WorkingDirectory=/var/lib/indexflow
ExecStart=/usr/local/bin/indexflow-core
Restart=always
RestartSec=5s
LimitNOFILE=65535

# Security sandbox settings
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/indexflow
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable --now indexflow

3. Deploying IndexFlow-cloud Commercial Web Server (www.indexflowing.com)

Step 1: Build the Binary

cd IndexFlow-cloud
cargo build --release
sudo cp target/release/indexflowing-web /usr/local/bin/indexflowing-web

Step 2: Systemd Unit Configuration

Create /etc/systemd/system/indexflowing-web.service:

[Unit]
Description=IndexFlowing Commercial Web Service
After=network.target

[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/indexflowing
ExecStart=/usr/local/bin/indexflowing-web
Restart=always
RestartSec=5s
Environment=SERVER_HOST=127.0.0.1
Environment=SERVER_PORT=8000
Environment=RUST_LOG=indexflowing_web=info,tower_http=info

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable --now indexflowing-web

4. Nginx Reverse Proxy for Web Applications

Create /etc/nginx/sites-available/indexflowing.com:

server {
    listen 80;
    listen [::]:80;
    server_name indexflowing.com www.indexflowing.com;
    return 301 https://www.indexflowing.com$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.indexflowing.com;

    ssl_certificate /etc/letsencrypt/live/www.indexflowing.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.indexflowing.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

5. SQLite Backup & Maintenance

IndexFlow operates SQLite in WAL mode. To create a live backup without taking the service offline:

# Atomic online backup using sqlite3 CLI
sqlite3 /var/lib/indexflow/indexflow.db ".backup '/backup/indexflow-$(date +%Y%m%d%H%M).db'"

Add to cron for automated daily backups:

0 2 * * * sqlite3 /var/lib/indexflow/indexflow.db ".backup '/backup/indexflow-$(date +\%Y\%m\%d).db'"