Deploying an APITable App
Introduction
APITable is a powerful open-source, API-first alternative to Airtable that combines the simplicity of spreadsheets with the power of a visual database. Built with modern technologies including Node.js and React, APITable enables teams to build collaborative applications, manage complex data relationships, and automate workflows without writing code. Whether you’re managing projects, tracking customers, organizing content, or building internal tools, APITable provides a flexible, self-hosted solution with complete control over your data.
APITable stands out for its:
- API-First Architecture: RESTful API and real-time updates via WebSocket for seamless integrations
- Visual Database Interface: Spreadsheet-like UI with powerful database capabilities including views, filtering, and sorting
- Collaborative Features: Real-time collaboration, permissions management, and team workspaces
- Rich Field Types: Support for attachments, formulas, links to other records, single/multiple select, dates, and more
- Automation Ready: Webhook support and API access for building automated workflows
- Self-Hosted Control: Complete data ownership and privacy with flexible deployment options
- Extensible Platform: Plugin system and widget framework for custom functionality
- Multi-Database Support: Compatible with MySQL, PostgreSQL, and MariaDB
This comprehensive guide walks you through deploying APITable on Klutch.sh using Docker, with detailed instructions for installation, configuration, persistent storage setup, database connectivity, and production-ready best practices. By the end of this guide, you’ll have a fully functional APITable instance ready for team collaboration.
Prerequisites
Before you begin deploying APITable, ensure you have the following:
- A Klutch.sh account
- A GitHub account with a repository for your APITable project
- Docker installed locally for testing (optional but recommended)
- Basic understanding of Docker, databases, and environment variables
- A MySQL, MariaDB, or PostgreSQL database instance (can be deployed separately on Klutch.sh or use an external service)
Installation and Setup
Step 1: Create Your Project Directory
Start by creating a new directory for your APITable deployment:
mkdir apitable-klutchcd apitable-klutchgit initThis directory will contain your Dockerfile and configuration files needed for deployment.
Step 2: Create the Dockerfile
Create a Dockerfile in your project root directory. This Dockerfile sets up the complete APITable environment with all necessary dependencies:
FROM node:18-bullseye-slim
# Install system dependenciesRUN apt-get update && apt-get install -y \ curl \ wget \ git \ python3 \ make \ g++ \ ca-certificates \ && rm -rf /var/lib/apt/lists/*
# Set working directoryWORKDIR /app
# Clone APITable repository (using a specific version for stability)RUN git clone --depth 1 --branch main https://github.com/apitable/apitable.git . || \ git clone --depth 1 https://github.com/apitable/apitable.git .
# Install dependenciesRUN npm install --production
# Create necessary directories for uploads and dataRUN mkdir -p /app/data/uploads /app/data/assets
# Expose the default APITable portEXPOSE 8080
# Set environment variables (override these in Klutch.sh)ENV NODE_ENV=productionENV PORT=8080
# Start APITableCMD ["npm", "start"]Note: This Dockerfile provides a basic setup. For a production environment with specific version pinning and optimizations, see the advanced configuration section below.
Step 3: Advanced Production Dockerfile
For production deployments with better caching, security, and performance:
FROM node:18-bullseye-slim AS builder
# Install build dependenciesRUN apt-get update && apt-get install -y \ curl \ wget \ git \ python3 \ make \ g++ \ ca-certificates \ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Clone APITable at a specific commit for reproducibilityARG APITABLE_VERSION=mainRUN git clone --depth 1 --branch ${APITABLE_VERSION} https://github.com/apitable/apitable.git .
# Install dependenciesRUN npm ci --production --no-audit --no-fund
# Production stageFROM node:18-bullseye-slim
# Install runtime dependencies onlyRUN apt-get update && apt-get install -y \ curl \ ca-certificates \ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy application from builderCOPY --from=builder /app /app
# Create data directoriesRUN mkdir -p /app/data/uploads /app/data/assets && \ chown -R node:node /app
# Switch to non-root user for securityUSER node
# Expose APITable portEXPOSE 8080
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:8080/health || exit 1
ENV NODE_ENV=productionENV PORT=8080
CMD ["npm", "start"]Step 4: Create Environment Configuration File
Create a .env.example file to document the required environment variables:
# APITable Configuration
# Database Configuration (MySQL, MariaDB, or PostgreSQL)DATABASE_TYPE=mysqlDATABASE_HOST=mysql-host.klutch.shDATABASE_PORT=3306DATABASE_NAME=apitableDATABASE_USERNAME=apitable_userDATABASE_PASSWORD=your-secure-password
# Redis Configuration (for caching and sessions)REDIS_HOST=redis-host.klutch.shREDIS_PORT=6379REDIS_PASSWORD=your-redis-passwordREDIS_DB=0
# APITable Application SettingsAPI_BASE_URL=https://example-app.klutch.shFRONTEND_URL=https://example-app.klutch.shCORS_ORIGINS=https://example-app.klutch.sh
# Security ConfigurationJWT_SECRET=your-generated-jwt-secret-minimum-32-charactersSESSION_SECRET=your-generated-session-secret-minimum-32-characters
# Storage ConfigurationSTORAGE_TYPE=localSTORAGE_PATH=/app/data/uploads
# Email Configuration (Optional - for notifications and invitations)MAIL_TYPE=smtpMAIL_HOST=smtp.example.comMAIL_PORT=587MAIL_USERNAME=noreply@example.comMAIL_PASSWORD=your-email-passwordMAIL_FROM=APITable <noreply@example.com>
# Application SettingsNODE_ENV=productionPORT=8080LOG_LEVEL=infoSecurity Warning: Never commit actual passwords or secrets to your repository. Use Klutch.sh environment variables for all sensitive values.
Step 5: Create Database Initialization Script (Optional)
Create a init-db.sql file for MySQL/MariaDB database initialization:
-- Create APITable databaseCREATE DATABASE IF NOT EXISTS apitable CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create APITable userCREATE USER IF NOT EXISTS 'apitable_user'@'%' IDENTIFIED BY 'your-secure-password';
-- Grant privilegesGRANT ALL PRIVILEGES ON apitable.* TO 'apitable_user'@'%';FLUSH PRIVILEGES;For PostgreSQL, create init-db.sql:
-- Create APITable databaseCREATE DATABASE apitable;
-- Create APITable userCREATE USER apitable_user WITH PASSWORD 'your-secure-password';
-- Grant privilegesGRANT ALL PRIVILEGES ON DATABASE apitable TO apitable_user;Step 6: Test Locally with Docker Compose (Optional)
For local testing before deploying to Klutch.sh, create a docker-compose.yml file:
version: '3.8'
services: apitable: build: . ports: - "8080:8080" environment: - DATABASE_TYPE=mysql - DATABASE_HOST=mysql - DATABASE_PORT=3306 - DATABASE_NAME=apitable - DATABASE_USERNAME=apitable_user - DATABASE_PASSWORD=apitable_pass - REDIS_HOST=redis - REDIS_PORT=6379 - JWT_SECRET=local-development-jwt-secret-change-in-production - SESSION_SECRET=local-development-session-secret-change-in-production - API_BASE_URL=http://localhost:8080 - FRONTEND_URL=http://localhost:8080 depends_on: - mysql - redis volumes: - apitable-data:/app/data
mysql: image: mysql:8.0 environment: - MYSQL_ROOT_PASSWORD=rootpass - MYSQL_DATABASE=apitable - MYSQL_USER=apitable_user - MYSQL_PASSWORD=apitable_pass volumes: - mysql-data:/var/lib/mysql command: --default-authentication-plugin=mysql_native_password
redis: image: redis:7-alpine volumes: - redis-data:/data
volumes: apitable-data: mysql-data: redis-data:Test locally:
# Build and start servicesdocker-compose up -d
# View logsdocker-compose logs -f apitable
# Access APITable at http://localhost:8080
# Stop services when donedocker-compose downNote: Docker Compose is for local development only. Klutch.sh does not support Docker Compose for deployment.
Step 7: Create Documentation
Create a README.md file with deployment instructions:
# APITable Deployment on Klutch.sh
This repository contains the configuration for deploying APITable on Klutch.sh.
## Quick Start
1. Deploy database and Redis on Klutch.sh or use external services2. Configure environment variables in Klutch.sh dashboard3. Deploy this repository to Klutch.sh4. Access your APITable instance at the provided URL
## Environment Variables
See `.env.example` for required environment variables.
## Documentation
For detailed deployment instructions, see the <a href="https://docs.klutch.sh/guides/open-source-software/apitable?utm_source=docs" target="_blank">Klutch.sh APITable guide</a>.Step 8: Push to GitHub
Commit your files and push to GitHub:
# Add filesgit add Dockerfile .env.example README.md docker-compose.yml
# Commitgit commit -m "Add APITable Dockerfile and configuration"
# Add remote and pushgit remote add origin https://github.com/yourusername/apitable-klutch.gitgit push -u origin mainImportant: Do not commit .env files with actual secrets. Only commit .env.example as a template.
Deploying to Klutch.sh
Now that your APITable project is ready and pushed to GitHub, follow these steps to deploy it on Klutch.sh with proper database connectivity and persistent storage.
Prerequisites for Deployment
Before deploying APITable, you’ll need:
-
Database Instance: Deploy MySQL, MariaDB, or PostgreSQL. You can:
- Deploy a database on Klutch.sh (recommended for simplicity)
- Use an external managed database service like AWS RDS, DigitalOcean Managed Databases, or PlanetScale
-
Redis Instance: Deploy Redis for caching and session management. You can:
- Deploy Redis on Klutch.sh
- Use an external Redis service like Redis Cloud or Upstash
Deployment Steps
-
Log in to Klutch.sh
Navigate to klutch.sh/app and sign in to your account.
-
Deploy Database and Redis (if not using external services)
Before deploying APITable, set up your database and Redis instances:
For MySQL/MariaDB:
- Create a new app in Klutch.sh
- Use the official MySQL 8.0 or MariaDB Docker image
- Configure TCP traffic type with internal port 3306
- Attach a persistent volume to
/var/lib/mysqlfor database storage - Note the connection details (hostname will be
[app-name].klutch.sh:8000)
For Redis:
- Create a new app in Klutch.sh
- Use the official Redis 7 Alpine Docker image
- Configure TCP traffic type with internal port 6379
- Optionally attach a persistent volume to
/datafor persistence - Note the connection details
-
Create a New Project for APITable
Go to your Klutch.sh dashboard and create a new project (e.g., “APITable Production”).
-
Create a New App
Click to create a new app and configure the following settings:
-
Select Your Repository
- Choose GitHub as your Git source
- Select the repository containing your Dockerfile
- Choose the branch you want to deploy (typically
main)
-
Configure Traffic Type
- Traffic Type: Select HTTP (APITable serves a web interface via HTTP)
- Internal Port: Set to
8080(the default port that APITable listens on)
-
Set Environment Variables
Add all required environment variables for your APITable configuration. Click “Add Environment Variable” for each of the following:
Database Configuration:
DATABASE_TYPE: Set tomysql,mariadb, orpostgresDATABASE_HOST: Your database hostname (e.g.,mysql-app.klutch.shfor TCP or external hostname)DATABASE_PORT: Database port (3306for MySQL/MariaDB,5432for PostgreSQL, or8000for Klutch.sh TCP apps)DATABASE_NAME: Database name (apitable)DATABASE_USERNAME: Database usernameDATABASE_PASSWORD: Database password (mark as secret)
Redis Configuration:
REDIS_HOST: Redis hostname (e.g.,redis-app.klutch.shor external hostname)REDIS_PORT: Redis port (6379or8000for Klutch.sh TCP apps)REDIS_PASSWORD: Redis password if configured (mark as secret)REDIS_DB: Redis database number (default:0)
Application Configuration:
API_BASE_URL: Your app URL (e.g.,https://example-app.klutch.sh)FRONTEND_URL: Same as API_BASE_URL (e.g.,https://example-app.klutch.sh)CORS_ORIGINS: Same as API_BASE_URL or comma-separated list of allowed originsPORT: Set to8080NODE_ENV: Set toproduction
Security Configuration:
JWT_SECRET: Generate a strong random string (minimum 32 characters, mark as secret)SESSION_SECRET: Generate a different strong random string (minimum 32 characters, mark as secret)
Optional Email Configuration:
MAIL_TYPE: Set tosmtpif using emailMAIL_HOST: SMTP server hostnameMAIL_PORT: SMTP port (typically587or465)MAIL_USERNAME: SMTP usernameMAIL_PASSWORD: SMTP password (mark as secret)MAIL_FROM: From address (e.g.,APITable <noreply@example.com>)
Storage Configuration:
STORAGE_TYPE: Set tolocal(for persistent volume storage)STORAGE_PATH: Set to/app/data/uploads
Generate Secrets: You can generate secure secrets using:
Terminal window # On your local machineopenssl rand -base64 32 -
Attach Persistent Volumes
APITable requires persistent storage for uploaded files and assets:
Click “Add Volume” and configure:
- Mount Path:
/app/data/uploads - Size: Choose appropriate size based on expected usage (recommended: 10GB minimum, 50GB+ for production)
Optionally add another volume for assets:
- Mount Path:
/app/data/assets - Size: 5GB or more
Important: Persistent volumes are critical for maintaining uploaded files, attachments, and assets across deployments.
- Mount Path:
-
Configure Compute Resources
APITable can be resource-intensive depending on usage:
- CPU: Minimum 1 CPU, recommended 2+ CPUs for production
- Memory: Minimum 2GB RAM, recommended 4GB+ RAM for production
- Instances: Start with 1 instance, scale horizontally as needed
-
Deploy Your Application
Click “Create” to start the deployment. Klutch.sh will:
- Detect your Dockerfile automatically
- Build the Docker image
- Attach the persistent volumes
- Configure environment variables
- Start your APITable container
- Assign a URL for external access (e.g.,
https://example-app.klutch.sh)
-
Monitor Deployment Progress
Watch the build logs to ensure everything compiles successfully. The initial build may take 5-10 minutes depending on network speed and build complexity.
-
Access Your APITable Instance
Once deployment is complete, navigate to your assigned URL (e.g.,
https://example-app.klutch.sh). You should see the APITable welcome screen. -
Create Your First Admin Account
On first access, APITable will prompt you to create an admin account:
- Enter your email address
- Set a strong password
- Complete the initial setup wizard
- Create your first workspace
Getting Started with APITable
After successful deployment, here’s how to start using APITable:
Create Your First Workspace
- Log in to your APITable instance at
https://example-app.klutch.sh - Click “Create Workspace” or use the default workspace
- Give your workspace a name (e.g., “My Team” or “Project Management”)
- Invite team members via email (requires email configuration)
Create Your First Datasheet
APITable organizes data in “datasheets” which combine spreadsheet simplicity with database power:
- In your workspace, click “New Datasheet”
- Choose a template or start blank
- Add columns with different field types:
- Text: Single-line or multi-line text
- Number: Integers, decimals, currency, percentages
- Date/DateTime: Calendar dates and timestamps
- Single Select: Choose one option from a list
- Multiple Select: Choose multiple options from a list
- Attachment: Upload files and images
- Link: Link to records in other datasheets
- Formula: Computed fields using formulas
- Checkbox: Boolean true/false values
- Rating: Star ratings
- Member: Assign team members
Example: Project Management Datasheet
Here’s a sample structure for a project management datasheet:
Columns:
- Project Name (Text): Name of the project
- Status (Single Select): Options: “Not Started”, “In Progress”, “Completed”, “On Hold”
- Priority (Single Select): Options: “Low”, “Medium”, “High”, “Critical”
- Assigned To (Member): Team member responsible
- Due Date (Date): Project deadline
- Budget (Currency): Project budget
- Progress (Rating): Visual progress indicator
- Notes (Multi-line Text): Additional information
- Attachments (Attachment): Related files and documents
Using Views
Create different views of your data:
- Grid View: Traditional spreadsheet layout
- Gallery View: Card-based visual layout, perfect for images
- Kanban View: Drag-and-drop board organized by a single-select field
- Gantt View: Timeline view for project scheduling
- Calendar View: Display records by date field
API Access
APITable provides a comprehensive REST API for integrations:
- Navigate to Settings → API
- Generate an API token
- Use the API documentation to make requests:
# Get all datasheets in a workspacecurl -X GET 'https://example-app.klutch.sh/api/v1/spaces/{spaceId}/datasheets' \ -H 'Authorization: Bearer YOUR_API_TOKEN'
# Get records from a datasheetcurl -X GET 'https://example-app.klutch.sh/api/v1/datasheets/{datasheetId}/records' \ -H 'Authorization: Bearer YOUR_API_TOKEN'
# Create a new recordcurl -X POST 'https://example-app.klutch.sh/api/v1/datasheets/{datasheetId}/records' \ -H 'Authorization: Bearer YOUR_API_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "records": [ { "fields": { "Project Name": "New Project", "Status": "Not Started", "Priority": "High" } } ] }'Automation with Webhooks
Set up webhooks to trigger actions when data changes:
- Go to Datasheet Settings → Webhooks
- Click “Create Webhook”
- Configure the webhook URL and events to watch
- APITable will POST data to your endpoint when triggers fire
Environment Variables Reference
Complete list of APITable environment variables you can configure in Klutch.sh:
Database Configuration
| Variable | Description | Required | Default | Example |
|---|---|---|---|---|
DATABASE_TYPE | Database type | Yes | mysql | mysql, mariadb, postgres |
DATABASE_HOST | Database hostname | Yes | - | mysql-app.klutch.sh |
DATABASE_PORT | Database port | Yes | 3306 | 3306, 5432, 8000 |
DATABASE_NAME | Database name | Yes | - | apitable |
DATABASE_USERNAME | Database user | Yes | - | apitable_user |
DATABASE_PASSWORD | Database password | Yes | - | secure-password |
DATABASE_SSL | Use SSL connection | No | false | true, false |
Redis Configuration
| Variable | Description | Required | Default | Example |
|---|---|---|---|---|
REDIS_HOST | Redis hostname | Yes | - | redis-app.klutch.sh |
REDIS_PORT | Redis port | Yes | 6379 | 6379, 8000 |
REDIS_PASSWORD | Redis password | No | - | redis-password |
REDIS_DB | Redis database number | No | 0 | 0, 1, 2 |
REDIS_SSL | Use SSL connection | No | false | true, false |
Application Configuration
| Variable | Description | Required | Default | Example |
|---|---|---|---|---|
API_BASE_URL | Base URL for API | Yes | - | https://example-app.klutch.sh |
FRONTEND_URL | Frontend URL | Yes | - | https://example-app.klutch.sh |
CORS_ORIGINS | Allowed CORS origins | Yes | - | https://example-app.klutch.sh |
PORT | Application port | No | 8080 | 8080 |
NODE_ENV | Node environment | No | production | production, development |
LOG_LEVEL | Logging level | No | info | debug, info, warn, error |
Security Configuration
| Variable | Description | Required | Default | Example |
|---|---|---|---|---|
JWT_SECRET | JWT signing secret | Yes | - | random-32-char-string |
SESSION_SECRET | Session signing secret | Yes | - | random-32-char-string |
COOKIE_DOMAIN | Cookie domain | No | - | .example.com |
Storage Configuration
| Variable | Description | Required | Default | Example |
|---|---|---|---|---|
STORAGE_TYPE | Storage backend | No | local | local, s3, oss |
STORAGE_PATH | Local storage path | No | /app/data/uploads | /app/data/uploads |
AWS_ACCESS_KEY_ID | AWS S3 access key | No | - | your-key |
AWS_SECRET_ACCESS_KEY | AWS S3 secret key | No | - | your-secret |
AWS_REGION | AWS S3 region | No | - | us-east-1 |
AWS_BUCKET | AWS S3 bucket name | No | - | apitable-uploads |
Email Configuration
| Variable | Description | Required | Default | Example |
|---|---|---|---|---|
MAIL_TYPE | Email service type | No | smtp | smtp |
MAIL_HOST | SMTP hostname | No | - | smtp.gmail.com |
MAIL_PORT | SMTP port | No | 587 | 587, 465 |
MAIL_USERNAME | SMTP username | No | - | user@example.com |
MAIL_PASSWORD | SMTP password | No | - | your-password |
MAIL_FROM | From address | No | - | APITable <noreply@example.com> |
MAIL_SECURE | Use TLS/SSL | No | true | true, false |
Custom Domains and SSL
To use a custom domain with your APITable deployment:
Add Custom Domain
- Navigate to your app in the Klutch.sh dashboard
- Go to Settings → Domains
- Click “Add Domain”
- Enter your custom domain (e.g.,
apitable.yourdomain.com) - Configure your DNS records as instructed:
- Add a CNAME record pointing to your Klutch.sh app URL
- Or add an A record pointing to the provided IP address
Update Environment Variables
After adding a custom domain, update these environment variables:
API_BASE_URL:https://apitable.yourdomain.comFRONTEND_URL:https://apitable.yourdomain.comCORS_ORIGINS:https://apitable.yourdomain.com
Klutch.sh automatically provisions and manages SSL/TLS certificates for your custom domain.
Production Best Practices
Security Recommendations
- Strong Secrets: Generate cryptographically secure random strings for
JWT_SECRETandSESSION_SECRET(minimum 32 characters) - Environment Variables: Store all sensitive credentials as environment variables in Klutch.sh, never commit them to your repository
- Database Security: Use strong passwords, create dedicated database users with minimal required privileges
- Regular Updates: Keep APITable, Node.js, and dependencies updated for security patches
- Access Control: Configure proper workspace and datasheet permissions
- HTTPS Only: Always use HTTPS URLs and enable HSTS if possible
- CORS Configuration: Set specific allowed origins instead of
*in production - Rate Limiting: Monitor API usage and implement rate limiting if needed
- Backup Strategy: Regular automated backups of database and persistent volumes
Performance Optimization
-
Database Optimization:
- Use indexed queries for better performance
- Regular ANALYZE and OPTIMIZE TABLE operations for MySQL
- Monitor slow queries and add indexes as needed
- Use connection pooling efficiently
-
Redis Caching:
- Ensure Redis is properly configured and accessible
- Monitor Redis memory usage and configure eviction policies
- Use Redis for session storage to enable horizontal scaling
-
Resource Allocation:
- Start with 2 CPU cores and 4GB RAM
- Scale vertically (more resources) or horizontally (more instances) based on usage
- Monitor CPU, memory, and disk I/O metrics
-
Content Delivery:
- Consider using a CDN for static assets if serving global users
- Configure appropriate caching headers for static content
- Optimize uploaded images and attachments
Database Management
-
Connection Pooling: Ensure proper connection pool sizing:
Terminal window # Add to environment variables if supportedDATABASE_POOL_SIZE=20DATABASE_MAX_CONNECTIONS=100 -
Regular Maintenance:
- Schedule regular database backups (daily recommended)
- Monitor database size and plan for growth
- Archive old datasheets if no longer actively used
- Optimize tables periodically
-
High Availability:
- Use managed database services with automated failover
- Configure read replicas for read-heavy workloads
- Implement database monitoring and alerting
Monitoring and Logging
Monitor these key metrics:
-
Application Metrics:
- Response times for API endpoints
- Error rates and stack traces
- Memory usage and garbage collection
- Active connections and sessions
-
Database Metrics:
- Query performance and slow queries
- Connection pool utilization
- Database size and growth rate
- Replication lag (if using replicas)
-
Infrastructure Metrics:
- CPU and memory usage
- Disk I/O and storage usage
- Network throughput
- Request rates and status codes
-
Log Management:
- Centralize logs for easier debugging
- Set appropriate log levels (use
infoorwarnin production) - Configure log rotation to prevent disk space issues
- Monitor for error patterns and anomalies
Backup and Disaster Recovery
Implement a comprehensive backup strategy:
-
Database Backups:
Terminal window # MySQL backup example (run as a scheduled job)mysqldump -h $DATABASE_HOST -P $DATABASE_PORT \-u $DATABASE_USERNAME -p$DATABASE_PASSWORD \$DATABASE_NAME > apitable-backup-$(date +%Y%m%d).sql -
Volume Snapshots:
- Regular snapshots of persistent volumes
- Test restore procedures periodically
- Store backups in separate location/region
-
Disaster Recovery Plan:
- Document recovery procedures
- Test full recovery process
- Maintain off-site backups
- Define Recovery Time Objective (RTO) and Recovery Point Objective (RPO)
Scaling APITable
As your usage grows, you may need to scale your APITable deployment:
Vertical Scaling
Increase resources for your existing instance:
- In Klutch.sh dashboard, go to your app settings
- Increase CPU cores (2, 4, 8 cores)
- Increase memory (4GB, 8GB, 16GB)
- Monitor performance improvements
Horizontal Scaling
Run multiple instances of APITable:
- Ensure you’re using external Redis for session storage
- Use a managed database that supports multiple connections
- Configure storage to use object storage (S3, OSS) instead of local volumes
- Increase instance count in Klutch.sh
- Klutch.sh will automatically load balance traffic
Note: For horizontal scaling, you must use shared storage (S3/OSS) for uploads instead of local volumes.
Database Scaling
For database-intensive workloads:
- Read Replicas: Configure read-only database replicas for read operations
- Sharding: Partition data across multiple databases (requires application-level support)
- Caching: Increase Redis cache size and TTL for frequently accessed data
- Optimization: Regularly analyze and optimize database queries
Troubleshooting
Application Won’t Start
Symptoms: App fails to start, shows error in logs
Solutions:
- Check all required environment variables are set
- Verify database connection details are correct
- Ensure database is accessible from your Klutch.sh app
- Check if database user has proper permissions
- Review startup logs for specific error messages
- Verify Dockerfile builds successfully locally
Database Connection Errors
Symptoms: “Unable to connect to database” errors
Solutions:
- Verify
DATABASE_HOSTandDATABASE_PORTare correct - For Klutch.sh TCP apps, ensure you’re using port 8000
- Test database connectivity from a debug container
- Check database credentials are correct
- Ensure database server is running and accepting connections
- Verify network connectivity between app and database
- Check for firewall rules blocking the connection
# Test MySQL connectionmysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PASSWORD $DATABASE_NAME
# Test PostgreSQL connectionpsql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USERNAME -d $DATABASE_NAMERedis Connection Issues
Symptoms: Session errors, cache failures
Solutions:
- Verify
REDIS_HOSTandREDIS_PORTare correct - Check Redis password if authentication is enabled
- Ensure Redis is running and accessible
- Test connection with
redis-cli:Terminal window redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_PASSWORD ping
File Upload Failures
Symptoms: Cannot upload files or attachments
Solutions:
- Verify persistent volume is attached at
/app/data/uploads - Check volume has sufficient free space
- Ensure correct file permissions (directory should be writable)
- Review
STORAGE_TYPEandSTORAGE_PATHenvironment variables - Check upload size limits in APITable configuration
- Review application logs for specific upload errors
Performance Issues
Symptoms: Slow response times, timeouts
Solutions:
- Monitor CPU and memory usage in Klutch.sh dashboard
- Check database query performance and add indexes
- Review Redis cache hit rates
- Increase compute resources (CPU/memory)
- Enable database query logging to identify slow queries
- Consider scaling horizontally with multiple instances
- Optimize large datasheets by archiving old data
Authentication Problems
Symptoms: Cannot log in, session expires immediately
Solutions:
- Verify
JWT_SECRETandSESSION_SECRETare set - Ensure secrets are at least 32 characters long
- Check cookie domain settings if using custom domain
- Clear browser cookies and try again
- Verify Redis is functioning properly for session storage
- Check system clock is synchronized (JWT tokens are time-sensitive)
API Requests Failing
Symptoms: API returns 401, 403, or CORS errors
Solutions:
- Verify API token is valid and not expired
- Check
CORS_ORIGINSincludes your frontend domain - Ensure
API_BASE_URLmatches your actual domain - Review API rate limiting settings
- Check request headers include proper authentication
- Verify API endpoint paths are correct
Advanced Configuration
Using Nixpacks Customizations
If you need to customize the build process with Nixpacks, you can use environment variables:
Change Build Command:
NIXPACKS_BUILD_CMD="npm install && npm run build"Change Start Command:
NIXPACKS_START_CMD="npm start"Install Additional Packages:
NIXPACKS_PKGS="python3 gcc make"Add these as environment variables in the Klutch.sh dashboard.
Using Object Storage (S3, OSS)
For production deployments with multiple instances, use object storage:
AWS S3 Configuration:
STORAGE_TYPE=s3AWS_ACCESS_KEY_ID=your-access-keyAWS_SECRET_ACCESS_KEY=your-secret-keyAWS_REGION=us-east-1AWS_BUCKET=apitable-uploadsAlibaba Cloud OSS Configuration:
STORAGE_TYPE=ossOSS_ACCESS_KEY_ID=your-access-keyOSS_ACCESS_KEY_SECRET=your-secret-keyOSS_REGION=oss-us-east-1OSS_BUCKET=apitable-uploadsCustom Plugins and Widgets
APITable supports custom plugins and widgets:
- Create your plugin following the APITable widget documentation
- Add plugin files to your repository
- Mount plugin directory as a volume or include in Docker image
- Configure plugin paths via environment variables
Upgrading APITable
To upgrade APITable to a new version:
Step 1: Update Dockerfile
Update the version in your Dockerfile:
# Change from:ARG APITABLE_VERSION=main
# To specific version:ARG APITABLE_VERSION=v1.5.0Or update the git clone command to use a specific tag.
Step 2: Backup Before Upgrading
Critical: Always backup before upgrading:
# Backup databasemysqldump -h $DATABASE_HOST -P $DATABASE_PORT \ -u $DATABASE_USERNAME -p$DATABASE_PASSWORD \ $DATABASE_NAME > apitable-backup-pre-upgrade.sql
# Backup persistent volumes# Use Klutch.sh dashboard to create volume snapshotStep 3: Deploy Update
# Commit changesgit add Dockerfilegit commit -m "Upgrade APITable to v1.5.0"git push
# Klutch.sh will automatically rebuild and redeployStep 4: Verify Upgrade
- Check application logs for any errors
- Test core functionality (login, create datasheet, upload file)
- Verify API endpoints are working
- Check database migrations completed successfully
Step 5: Rollback if Needed
If issues occur:
- Revert Dockerfile changes
- Push to GitHub to trigger rebuild
- Restore database from backup if necessary
- Restore volume snapshot if needed
Additional Resources
- APITable Official Website
- APITable GitHub Repository
- APITable Official Documentation
- APITable User Guide
- APITable API Documentation
- Klutch.sh Getting Started Guide
- Klutch.sh Persistent Volumes Guide
- Klutch.sh Networking Guide
- Klutch.sh Custom Domains Guide
- Node.js Docker Images
- MySQL Docker Images
- PostgreSQL Docker Images
- Redis Docker Images
Conclusion
Deploying APITable on Klutch.sh with Docker provides a powerful, self-hosted collaborative database platform with complete control over your data. By following this comprehensive guide, you’ve set up a production-ready APITable instance with proper database connectivity, Redis caching, persistent storage, security configurations, and scalability options.
Your APITable deployment is now ready to serve as the foundation for building collaborative applications, managing complex data relationships, and automating workflows for your team. With the API-first architecture, you can integrate APITable with your existing tools and build custom solutions tailored to your specific needs.
For ongoing success, remember to implement regular backups, monitor performance metrics, keep your deployment updated with the latest security patches, and scale resources as your usage grows.