Deployment
Knitly Deployment Guide
Section titled “Knitly Deployment Guide”System Requirements
Section titled “System Requirements”| Component | Minimum | Recommended |
|---|---|---|
| CPU | 1 core | 2+ cores |
| RAM | 512MB | 1GB+ |
| Storage | 5GB | 10GB+ |
| Node.js | Bun | Latest |
Deployment Options
Section titled “Deployment Options”1. Docker (Recommended)
Section titled “1. Docker (Recommended)”Quick Start
Section titled “Quick Start”git clone https://github.com/knitly-app/knitly.gitcd knitly
# Edit environment values directly in docker-compose.yml, then:docker compose up -dOpen http://localhost:3000 — the first user to sign up becomes admin.
Compose Configuration
Section titled “Compose Configuration”The shipped docker-compose.yml runs a single service and stores all state in a named volume mounted at /data. Set your production values in the environment block:
services: knitly: build: . ports: - "3000:3000" volumes: - knitly-data:/data environment: - NODE_ENV=production - PORT=3000 - BASE_URL=https://your-domain.com - ALLOWED_ORIGINS=https://your-domain.com - DATABASE_PATH=/data/knitly.db - LOCAL_UPLOAD_DIR=/data/uploads - USE_LOCAL_STORAGE=true restart: unless-stopped
volumes: knitly-data:The image builds the frontend, runs on port 3000, and ships a healthcheck against /api/health. Both the SQLite database and uploads live under /data, so backing up that one volume captures everything.
Backups
Section titled “Backups”# Copy the database out of the running containerdocker compose cp knitly:/data/knitly.db ./knitly.db.$(date +%Y%m%d)2. Bare Metal (systemd)
Section titled “2. Bare Metal (systemd)”Prerequisites
Section titled “Prerequisites”# Ubuntu/Debiansudo apt updatesudo apt install bun sqlite3 ffmpeg git
# Arch Linuxsudo pacman -Sy bun sqlite ffmpeg gitInstallation
Section titled “Installation”# Clone repositorygit clone https://github.com/knitly-app/knitly.gitcd knitly
# Install dependenciesbun install
# Build frontendbun run build
# Create environment filecp deploy/env.production.example server/.env.production# Edit with your values
# Create data directoriesmkdir -p uploadsSystemd Service
Section titled “Systemd Service”The repository ships a unit at deploy/knitly.service (and deploy/knitly.openrc for OpenRC systems). A minimal unit looks like this:
[Unit]Description=Knitly Social NetworkAfter=network.target
[Service]Type=simpleUser=knitlyWorkingDirectory=/opt/knitlyExecStart=/usr/bin/bun --cwd /opt/knitly run startRestart=alwaysRestartSec=10Environment=NODE_ENV=productionEnvironment=BASE_URL=https://your-domain.comEnvironment=ALLOWED_ORIGINS=https://your-domain.com
[Install]WantedBy=multi-user.targetConfiguration can also live in server/.env.production instead of Environment= lines.
Setup Service
Section titled “Setup Service”# Create usersudo useradd -r -s /bin/false knitly
# Copy the built app (repo root, no app/ subdirectory)sudo cp -r /path/to/knitly /opt/knitlysudo chown -R knitly:knitly /opt/knitly
# Install and enable the servicesudo cp /opt/knitly/deploy/knitly.service /etc/systemd/system/sudo systemctl daemon-reloadsudo systemctl enable knitlysudo systemctl start knitlysudo systemctl status knitly3. Reverse Proxy Configuration
Section titled “3. Reverse Proxy Configuration”Caddy (Recommended)
Section titled “Caddy (Recommended)”Create /etc/caddy/Caddyfile:
knitly.example.com { reverse_proxy localhost:3000
# Security headers (optional, Knitly adds its own) header { X-Frame-Options "DENY" X-Content-Type-Options "nosniff" Referrer-Policy "strict-origin-when-cross-origin" }
# Rate limiting (optional, Knitly handles this)}Install Caddy:
# Ubuntu/Debiansudo apt install caddy
# Arch Linuxsudo pacman -S caddyCreate /etc/nginx/sites-available/knitly:
server { listen 80; server_name knitly.example.com;
location / { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; 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; }}Enable site:
sudo ln -s /etc/nginx/sites-available/knitly /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl reload nginx4. DigitalOcean App Platform
Section titled “4. DigitalOcean App Platform”- Connect your GitHub repository
- Set build command:
bun install && bun run build - Set start command:
bun run start - Add environment variables
- Set instance size: $12/mo (2GB RAM recommended)
5. Railway
Section titled “5. Railway”- Create new project
- Connect GitHub repository
- Add environment variables
- Set port to 3000
- Deploy
SSL/TLS Configuration
Section titled “SSL/TLS Configuration”Let’s Encrypt with Caddy
Section titled “Let’s Encrypt with Caddy”Caddy automatically obtains and renews Let’s Encrypt certificates:
knitly.example.com { reverse_proxy localhost:3000}Manual SSL with Nginx
Section titled “Manual SSL with Nginx”server { listen 443 ssl; server_name knitly.example.com;
ssl_certificate /etc/letsencrypt/live/knitly.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/knitly.example.com/privkey.pem;
# Strong SSL settings ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256; ssl_prefer_server_ciphers on;
location / { proxy_pass http://localhost:3000; # ... proxy settings }}Monitoring
Section titled “Monitoring”Health Check
Section titled “Health Check”curl https://your-domain.com/api/healthDocker:
docker compose logs -fsystemd:
journalctl -u knitly -fMetrics
Section titled “Metrics”Monitor with:
- CPU usage:
toporhtop - Memory:
free -h - Disk:
df -h - Network:
nethogs
Scaling
Section titled “Scaling”Horizontal Scaling
Section titled “Horizontal Scaling”Knitly is designed for single-instance deployment. For larger deployments:
- Use a reverse proxy/load balancer
- Multiple instances behind load balancer (sticky sessions required)
- External database (PostgreSQL/MySQL) - not currently supported
Vertical Scaling
Section titled “Vertical Scaling”- Upgrade server resources
- Enable S3 storage for media
- Use CDN for static assets
Security Checklist
Section titled “Security Checklist”- HTTPS enabled (Let’s Encrypt)
- Firewall configured (only ports 80, 443, 22 open)
- Environment variables set
- Admin account created
- Regular backups configured
- Security updates enabled
- Rate limiting active
- Security headers configured
Troubleshooting
Section titled “Troubleshooting”Port Already in Use
Section titled “Port Already in Use”# Find processlsof -i :3000
# Kill processkill -9 <PID>Database Locked
Section titled “Database Locked”# Stop serversudo systemctl stop knitly
# Kill any remaining processeskill -9 $(pgrep -f knitly)
# Restartsudo systemctl start knitlyPermission Issues
Section titled “Permission Issues”# Fix permissionssudo chown -R knitly:knitly /opt/knitlysudo chmod -R 755 /opt/knitlyLogs Not Showing
Section titled “Logs Not Showing”# Check journaljournalctl -u knitly -n 50
# Check log directoryls -la /opt/knitly/server/logs/Maintenance
Section titled “Maintenance”Updates
Section titled “Updates”# Pull latest changescd /opt/knitlygit pull origin main
# Install dependenciesbun install
# Rebuildbun run build
# Restartsudo systemctl restart knitlyDatabase Maintenance
Section titled “Database Maintenance”# Backupcp knitly.db knitly.db.backup.$(date +%Y%m%d)
# Optimizesqlite3 knitly.db "VACUUM;"Cleanup Old Files
Section titled “Cleanup Old Files”# Remove old uploads (manual review recommended)find uploads -type f -mtime +365 -delete