Deploying Fugu
Introduction
Fugu is a powerful open-source team chat and collaboration platform designed for modern teams who need reliable, self-hosted communication tools. Built with scalability and extensibility in mind, Fugu provides real-time messaging, file sharing, channel management, and team collaboration features without the vendor lock-in of proprietary solutions.
Deploying Fugu on Klutch.sh gives you enterprise-grade infrastructure with automatic Docker detection, persistent storage for chat history and files, secure environment variable management, and seamless scaling. Whether you’re running a small team or managing organization-wide communications, this guide will walk you through deploying Fugu with a Dockerfile on Klutch.sh from scratch to production.
This comprehensive guide covers everything you need: installing and setting up Fugu locally, creating a production-ready Dockerfile, configuring persistent volumes for data retention, managing environment variables securely, deploying to Klutch.sh, and following production best practices for reliability and performance.
Prerequisites
Before you begin deploying Fugu on Klutch.sh, ensure you have:
- A Klutch.sh account with access to the dashboard
- A GitHub account and repository for your Fugu project
- Basic familiarity with Docker, containers, and environment variables
- (Recommended for production) Access to a managed PostgreSQL or MySQL database
- Node.js and npm installed locally for development and testing
Getting Started: Installing Fugu Locally
Before deploying to Klutch.sh, it’s helpful to understand how Fugu works by running it locally. This section guides you through installing Fugu, understanding its architecture, and creating a basic setup.
1. Clone and Set Up Fugu
First, create a new directory for your Fugu project and initialize it:
mkdir fugu-appcd fugu-appnpm init -y2. Install Fugu Dependencies
Install Fugu and its core dependencies:
npm install fugu-core fugu-server3. Create a Basic Configuration File
Create a config.json file in your project root with basic settings:
{ "port": 3000, "database": { "type": "sqlite", "path": "./data/fugu.db" }, "storage": { "type": "local", "path": "./data/uploads" }, "session": { "secret": "your-session-secret-change-this" }}4. Create a Start Script
Create a start.js file to bootstrap Fugu:
// start.js - Example startup script// Note: Adjust based on your specific Fugu installation methodconst config = require('./config.json');
// Example using Express-based setupconst app = require('./app');
const PORT = config.port || 3000;
app.listen(PORT, '0.0.0.0', () => { console.log(`Fugu is running on port ${PORT}`);});5. Test Locally
Run Fugu locally to verify everything works:
node start.jsVisit http://localhost:3000 in your browser. You should see the Fugu interface and be able to create an account.
Sample Code: Basic Configuration Example
Here’s a simple example of environment-based configuration:
// config.js - Environment-based configurationmodule.exports = { port: process.env.PORT || 3000, host: process.env.HOST || '0.0.0.0',
database: { type: process.env.DATABASE_TYPE || 'sqlite', host: process.env.DATABASE_HOST, port: process.env.DATABASE_PORT, name: process.env.DATABASE_NAME, user: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, },
session: { secret: process.env.SESSION_SECRET || 'change-this-in-production', },
storage: { path: process.env.STORAGE_PATH || '/app/data/uploads', }};Creating a Production-Ready Dockerfile
Klutch.sh automatically detects a Dockerfile if present in your repository’s root directory. Here’s how to create a production-ready Dockerfile for Fugu.
Basic Dockerfile
Create a Dockerfile in your project root:
# Use official Node.js LTS imageFROM node:18-alpine
# Set working directoryWORKDIR /app
# Copy package filesCOPY package*.json ./
# Install dependenciesRUN npm ci --production --no-audit
# Copy application filesCOPY . .
# Create data directoriesRUN mkdir -p /app/data/uploads /app/data/logs
# Set environment to productionENV NODE_ENV=production
# Expose Fugu portEXPOSE 3000
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start FuguCMD ["node", "start.js"]Advanced Multi-Stage Dockerfile
For optimized production deployments, use a multi-stage build:
# Build stageFROM node:18-alpine AS builder
WORKDIR /app
# Install build dependenciesCOPY package*.json ./RUN npm ci --include=dev
# Copy source codeCOPY . .
# Build Fugu (if applicable)RUN npm run build || true
# Production stageFROM node:18-alpine
# Install dumb-init for proper signal handlingRUN apk add --no-cache dumb-init
# Create non-root userRUN addgroup -g 1001 fugu && \ adduser -D -u 1001 -G fugu fugu
WORKDIR /app
# Copy package files and install production dependenciesCOPY package*.json ./RUN npm ci --production --no-audit && \ npm cache clean --force
# Copy built application from builderCOPY --from=builder --chown=fugu:fugu /app .
# Create necessary directories with proper permissionsRUN mkdir -p /app/data/uploads /app/data/logs && \ chown -R fugu:fugu /app/data
# Switch to non-root userUSER fugu
# Set production environmentENV NODE_ENV=production
# Expose portEXPOSE 3000
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Use dumb-init to handle signals properlyENTRYPOINT ["dumb-init", "--"]
# Start applicationCMD ["node", "start.js"]Dockerfile with Database Support
If using PostgreSQL or MySQL, here’s a configuration-ready Dockerfile:
FROM node:18-alpine
WORKDIR /app
# Install system dependenciesRUN apk add --no-cache \ postgresql-client \ mysql-client \ ca-certificates
COPY package*.json ./RUN npm ci --production --no-audit
COPY . .
RUN mkdir -p /app/data/uploads /app/data/logs
ENV NODE_ENV=production
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
CMD ["node", "start.js"]Configuring Persistent Storage
Fugu requires persistent storage for chat messages, uploaded files, user data, and configuration. Without persistent volumes, all data will be lost when the container restarts.
Required Storage Paths
Fugu typically stores data in these locations:
/app/data- Main data directory for databases (if using SQLite)/app/data/uploads- User-uploaded files, images, and attachments/app/data/logs- Application logs/app/config- Configuration files (if not using environment variables)
Setting Up Volumes in Klutch.sh
-
In the Klutch.sh dashboard, navigate to your app settings
-
Go to the Volumes section
-
Click Add Volume and configure:
- Mount Path:
/app/data - Size: 10GB (adjust based on expected usage)
- Mount Path:
-
For larger deployments with many files, add a separate volume for uploads:
- Mount Path:
/app/data/uploads - Size: 50GB or more
- Mount Path:
-
Save your volume configuration
Volume Configuration Example
When creating your app, you’ll specify mount paths for persistent volumes. Here’s what the configuration looks like:
Mount Path: /app/dataSize: 10GB
Mount Path: /app/data/uploadsSize: 50GBImportant Notes:
- Volumes persist across deployments and container restarts
- Data in volumes is not deleted when you update your app
- Ensure your Dockerfile creates these directories with proper permissions
- For production, regularly back up your volumes using Klutch.sh’s backup features
Environment Variables Configuration
Fugu requires several environment variables for secure operation. Configure these in the Klutch.sh dashboard before deploying.
Essential Environment Variables
# Application SettingsNODE_ENV=productionPORT=3000BASE_URL=https://example-app.klutch.sh
# Database Configuration (PostgreSQL example)DATABASE_TYPE=postgresqlDATABASE_HOST=your-postgres-host.klutch.shDATABASE_PORT=5432DATABASE_NAME=fugu_productionDATABASE_USER=fugu_userDATABASE_PASSWORD=your-secure-password
# Session SecuritySESSION_SECRET=your-long-random-session-secret-change-thisJWT_SECRET=your-long-random-jwt-secret-change-this
# File StorageSTORAGE_TYPE=localSTORAGE_PATH=/app/data/uploadsMAX_FILE_SIZE=10485760
# Email Configuration (for notifications)SMTP_HOST=smtp.example.comSMTP_PORT=587SMTP_USER=notifications@example.comSMTP_PASSWORD=your-smtp-passwordSMTP_FROM=noreply@example.com
# Redis (optional, for scaling)REDIS_HOST=redis.klutch.shREDIS_PORT=6379REDIS_PASSWORD=your-redis-password
# SecurityENABLE_RATE_LIMITING=trueRATE_LIMIT_WINDOW=900000RATE_LIMIT_MAX_REQUESTS=100
# LoggingLOG_LEVEL=infoLOG_PATH=/app/data/logsDatabase Options
SQLite (Development/Small Teams)
DATABASE_TYPE=sqliteDATABASE_PATH=/app/data/fugu.dbPostgreSQL (Recommended for Production)
DATABASE_TYPE=postgresqlDATABASE_HOST=postgres.example.comDATABASE_PORT=5432DATABASE_NAME=fuguDATABASE_USER=fugu_userDATABASE_PASSWORD=secure_passwordDATABASE_SSL=trueDATABASE_POOL_MIN=2DATABASE_POOL_MAX=10MySQL
DATABASE_TYPE=mysqlDATABASE_HOST=mysql.example.comDATABASE_PORT=3306DATABASE_NAME=fuguDATABASE_USER=fugu_userDATABASE_PASSWORD=secure_passwordSetting Environment Variables in Klutch.sh
-
Log in to Klutch.sh dashboard
-
Navigate to your Fugu app
-
Go to Settings → Environment Variables
-
Click Add Variable for each environment variable
-
Mark sensitive variables (passwords, secrets) as Secret to prevent them from being displayed in logs
-
Save your configuration
Customizing Build and Start Commands with Nixpacks
If you need to customize Fugu’s build or start behavior, use Nixpacks environment variables:
# Custom build commandBUILD_COMMAND=npm run build && npm run migrate
# Custom start commandSTART_COMMAND=node --max-old-space-size=2048 start.js
# Install additional dependenciesNIXPACKS_INSTALL_CMD=npm ci && npm install sharpDeploying to Klutch.sh
Now that you have your Dockerfile, configuration, and environment variables ready, let’s deploy Fugu to Klutch.sh.
Step-by-Step Deployment
-
Push Your Code to GitHub
Commit your Dockerfile and application code to your GitHub repository:
Terminal window git initgit add .git commit -m "Initial Fugu setup with Dockerfile"git remote add origin https://github.com/yourusername/fugu-app.gitgit push -u origin main -
Log in to Klutch.sh
Visit klutch.sh/app and log in to your account.
-
Create a New Project
If you don’t have a project yet:
- Click Create Project
- Give it a descriptive name like “Team Communication”
- Click Create
-
Create a New App
- Click Create App or Create a new app
- Enter your app name (e.g., “fugu-production”)
- Select your GitHub repository from the list
- Choose the branch to deploy (e.g.,
main)
-
Configure App Settings
Klutch.sh automatically detects your Dockerfile in the root directory.
- Traffic Type: Select HTTP (Fugu is a web application)
- Internal Port: Enter
3000(the port Fugu listens on inside the container) - Region: Choose a region close to your users
- Compute: Select appropriate resources (minimum 1GB RAM recommended)
- Instances: Start with 1, scale up as needed
-
Add Environment Variables
Go to the Environment Variables section and add all the variables from the previous section. Remember to mark sensitive values as secrets.
-
Attach Persistent Volumes
In the Volumes section:
- Add a volume with mount path
/app/dataand size 10GB - Add another volume with mount path
/app/data/uploadsand size 50GB
- Add a volume with mount path
-
Deploy
- Review your configuration
- Click Create to start the deployment
- Klutch.sh will build your Docker image and deploy your app
-
Monitor Deployment
Watch the build logs in real-time. The deployment process includes:
- Pulling your code from GitHub
- Building the Docker image from your Dockerfile
- Creating and attaching volumes
- Starting the container
- Health checks
-
Access Your App
Once deployed, your Fugu instance will be available at:
https://example-app.klutch.shReplace
example-appwith your actual app name.
Verifying the Deployment
After deployment completes:
- Visit your app URL in a browser
- You should see the Fugu login/signup page
- Create an admin account
- Test creating a channel and sending messages
- Upload a file to verify storage is working
- Check the Klutch.sh dashboard for metrics and logs
Production Best Practices
Database Configuration
For production deployments, always use an external database:
- PostgreSQL (recommended): Offers excellent performance, JSONB support, and full-text search
- MySQL: Good alternative with wide ecosystem support
- Deploy your database on Klutch.sh or use a managed service
- Enable SSL/TLS connections between Fugu and the database
- Use connection pooling to handle concurrent users efficiently
Security Hardening
-
Strong Secrets
- Generate long, random values for
SESSION_SECRETandJWT_SECRET - Use a password manager or
openssl rand -base64 32
- Generate long, random values for
-
HTTPS Only
- Klutch.sh provides automatic HTTPS for all apps
- Set
BASE_URLto usehttps://
-
Rate Limiting
- Enable rate limiting to prevent abuse
- Configure appropriate limits based on expected usage
-
Regular Updates
- Keep Fugu and dependencies updated
- Monitor security advisories
- Use Dependabot or Renovate for automated dependency updates
-
Access Control
- Implement strong password policies
- Enable two-factor authentication if supported
- Use SSO/SAML for enterprise deployments
Performance Optimization
-
Redis for Session Storage
For multi-instance deployments, use Redis:
Terminal window REDIS_HOST=redis.klutch.shREDIS_PORT=6379SESSION_STORE=redis -
CDN for Static Assets
Serve uploaded files through a CDN for better performance:
Terminal window STORAGE_TYPE=s3S3_BUCKET=fugu-uploadsS3_REGION=us-east-1CDN_URL=https://cdn.example.com -
Database Indexing
Ensure proper indexes on:
- Message tables (channel_id, created_at)
- User tables (username, email)
- Search fields for full-text queries
-
Horizontal Scaling
- Increase instances in Klutch.sh for higher load
- Use Redis for shared session state
- Configure load balancing (handled by Klutch.sh)
-
Monitoring and Logging
- Set
LOG_LEVEL=warnin production to reduce noise - Use structured logging with JSON output
- Monitor CPU, memory, and database connections
- Set up alerts for error rates and response times
- Set
Backup Strategy
-
Database Backups
- Configure automated daily backups
- Test restoration procedures regularly
- Keep backups for at least 30 days
-
Volume Backups
- Regularly backup the
/app/data/uploadsvolume - Store backups in a separate region/provider
- Implement retention policies
- Regularly backup the
-
Configuration Backups
- Version control all environment variables
- Document any manual configuration changes
- Keep encrypted backups of secrets
Scaling Considerations
-
Vertical Scaling
- Start with 1GB RAM, 1 CPU
- Monitor resource usage
- Scale up to 2-4GB RAM for 100+ concurrent users
-
Horizontal Scaling
- Use multiple instances for high availability
- Configure Redis for session sharing
- Database connection pooling becomes critical
-
Traffic Management
- Set internal port to
3000 - Klutch.sh handles HTTPS termination and load balancing
- Traffic type should be HTTP for web socket support
- Set internal port to
Troubleshooting Common Issues
App Won’t Start
Symptoms: Container starts but app doesn’t respond
Solutions:
- Check environment variables are set correctly
- Verify database connection (host, port, credentials)
- Check logs in Klutch.sh dashboard for error messages
- Ensure internal port is set to
3000(or your configured port)
Database Connection Errors
Symptoms: “Connection refused” or “Authentication failed”
Solutions:
- Verify database host is reachable from Klutch.sh
- Check database credentials in environment variables
- Ensure database allows connections from Klutch.sh IP ranges
- Test connection using database client tools
File Upload Failures
Symptoms: Files won’t upload or uploads return errors
Solutions:
- Verify volumes are properly attached
- Check directory permissions in Dockerfile
- Ensure
MAX_FILE_SIZEis set appropriately - Monitor available disk space on volumes
High Memory Usage
Symptoms: App restarts frequently, out of memory errors
Solutions:
- Increase instance size in Klutch.sh
- Check for memory leaks in application logs
- Reduce
DATABASE_POOL_MAXconnections - Optimize large file handling
Slow Performance
Symptoms: Slow message delivery, high latency
Solutions:
- Add Redis for session caching
- Enable database query logging and optimize slow queries
- Increase instance count for horizontal scaling
- Use CDN for static assets and uploads
- Check database connection pool settings
Updating Your Deployment
When you need to update Fugu:
-
Update Your Code
Terminal window git pull origin main# Make your changesgit add .git commit -m "Update Fugu configuration"git push origin main -
Trigger Redeployment
- Klutch.sh automatically rebuilds when you push to GitHub
- Or manually trigger a rebuild in the dashboard
- Monitor the build logs
-
Database Migrations If updating includes database schema changes:
Terminal window # Add to Dockerfile or use a migration jobRUN npm run migrate -
Zero-Downtime Updates
- Klutch.sh performs rolling updates automatically
- New containers start before old ones stop
- Health checks ensure new version is ready
Advanced Configuration
Custom Domain Setup
- In Klutch.sh dashboard, go to your app settings
- Navigate to Domains section
- Click Add Custom Domain
- Enter your domain (e.g.,
chat.example.com) - Follow DNS configuration instructions
- Update
BASE_URLenvironment variable to match your domain - Klutch.sh automatically provisions SSL/TLS certificates
Email Notifications
Configure SMTP for user notifications:
SMTP_HOST=smtp.sendgrid.netSMTP_PORT=587SMTP_USER=apikeySMTP_PASSWORD=your-sendgrid-api-keySMTP_FROM=notifications@example.comENABLE_EMAIL_NOTIFICATIONS=trueWebhooks Integration
Enable webhooks for external integrations:
ENABLE_WEBHOOKS=trueWEBHOOK_SECRET=your-webhook-secretALLOWED_WEBHOOK_DOMAINS=example.com,api.example.comReal-Time Features
Optimize WebSocket connections:
WEBSOCKET_ENABLED=trueWEBSOCKET_PATH=/socketWEBSOCKET_PING_INTERVAL=25000WEBSOCKET_PING_TIMEOUT=60000Resources
For more information about Fugu and Klutch.sh:
- Fugu GitHub Repository
- Klutch.sh Quick Start Guide
- Klutch.sh Volumes Guide
- Klutch.sh Apps Documentation
- Klutch.sh Deployments Guide
- Klutch.sh Networking Guide
- Docker Dockerfile Reference
- Nixpacks Documentation
Conclusion
You now have a comprehensive understanding of deploying Fugu on Klutch.sh with Docker. This guide covered installation, Dockerfile creation, persistent storage configuration, environment variables, deployment steps, and production best practices.
Fugu on Klutch.sh provides a powerful, self-hosted team collaboration platform with the reliability and scalability of modern cloud infrastructure. Whether you’re running a small team chat or enterprise-wide communications, Klutch.sh’s automatic Docker detection, persistent volumes, and seamless scaling capabilities make it an ideal platform for hosting Fugu.
Start deploying today and give your team the chat platform they deserve!