Multi-tenant PocketBase SaaS deployment automation tool
PocketFast is a powerful automation tool that enables you to rapidly deploy isolated PocketBase instances for multiple users or clients. It's designed for SaaS providers, development agencies, or anyone who needs to quickly spin up separate PocketBase databases with custom subdomains.
PocketFast automates the entire process of creating isolated PocketBase instances for multiple users:
- 🚀 Instant Deployment: Deploy a new PocketBase instance in seconds
- 🏠 Multi-tenancy: Each user gets their own isolated database and instance
- 🌐 Custom Subdomains: Automatic subdomain creation (e.g.,
user1.yourdomain.com) - 🔐 Admin Setup: Pre-configured admin accounts with secure random passwords
- 📱 Cloudflare Integration: Automatic DNS record creation and tunnel configuration
- ⚡ Reverse Proxy: NGINX configuration for proper routing and SSL termination
- SaaS Platforms - Offer PocketBase as a service to multiple clients
- Development Agencies - Quickly provision databases for different projects
- Multi-tenant Applications - Isolate data between different user groups
- Testing & Development - Spin up isolated environments for different features
- Client Projects - Give each client their own PocketBase instance
User Request → deploy_pocketbase.sh → Docker Container → PocketBase Instance
↓
Cloudflare DNS + Tunnel → Custom Subdomain → NGINX Proxy
- Docker Container: Isolated PocketBase instance per user
- Data Isolation: Separate data directories for each user
- Network Isolation: Unique ports for each instance
- Domain Management: Automatic subdomain creation via Cloudflare API
- Reverse Proxy: NGINX handles routing and SSL termination
- Docker installed and running
- Cloudflare account with API access
- NGINX configured on your server
- Cloudflare Tunnel (cloudflared) set up
export CLOUDFLARE_API_TOKEN="your_api_token"
export CLOUDFLARE_ZONE_ID="your_zone_id"
export CLOUDFLARE_TUNNEL_TARGET="your_tunnel_target"
export DOMAIN="yourdomain.com"./deploy_pocketbase.sh username port_numberExample:
./deploy_pocketbase.sh client1 8090- ✅ Creates isolated data directory for the user
- ✅ Spins up Docker container with PocketBase
- ✅ Creates admin account with secure password
- ✅ Adds DNS record for
client1.yourdomain.com - ✅ Configures NGINX reverse proxy
- ✅ Updates Cloudflare Tunnel configuration
- ✅ Restarts services to apply changes
- URL:
http://client1.yourdomain.com - Admin Panel:
http://client1.yourdomain.com/_/ - Credentials:
client1@example.com/[generated_password]
PocketFast/
├── deploy_pocketbase.sh # Main deployment automation script
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # PocketBase container definition
├── package.json # Node.js dependencies
├── data/ # User data directories (auto-created)
│ ├── user1/ # Isolated data for user1
│ ├── user2/ # Isolated data for user2
│ └── ...
└── README.md # This file
| Variable | Description | Example |
|---|---|---|
CLOUDFLARE_API_TOKEN |
Cloudflare API token for DNS management | abc123... |
CLOUDFLARE_ZONE_ID |
Your Cloudflare zone ID | f28cbc12... |
CLOUDFLARE_TUNNEL_TARGET |
Cloudflare Tunnel target | tunnel.cfargotunnel.com |
DOMAIN |
Your main domain | yourdomain.com |
- Each user gets a unique port (e.g., 8090, 8091, 8092)
- Ports are mapped to Docker containers
- NGINX routes traffic based on subdomain
- Data Isolation: Each user's data is completely separated
- Random Passwords: Secure admin passwords generated automatically
- Environment Variables: No hardcoded secrets
- Network Isolation: Each instance runs on its own port
- Reverse Proxy: Proper SSL termination and header handling
# Deploy for different clients
./deploy_pocketbase.sh acme_corp 8090
./deploy_pocketbase.sh startup_inc 8091
./deploy_pocketbase.sh enterprise_llc 8092# Deploy for different features
./deploy_pocketbase.sh feature_a 8090
./deploy_pocketbase.sh feature_b 8091
./deploy_pocketbase.sh testing 8092# Deploy for different projects
./deploy_pocketbase.sh project_alpha 8090
./deploy_pocketbase.sh project_beta 8091
./deploy_pocketbase.sh project_gamma 8092docker ps --filter "name=pocketbase_"docker stop pocketbase_usernamedocker start pocketbase_usernamedocker rm -f pocketbase_username
rm -rf ./data/username-
Port Already in Use:
# Check what's using the port netstat -tulpn | grep :8090
-
Cloudflare API Errors:
- Verify API token permissions
- Check zone ID is correct
- Ensure tunnel target is valid
-
NGINX Configuration:
# Test configuration sudo nginx -t # Reload configuration sudo systemctl reload nginx
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License.
If you encounter issues or have questions:
- Check the troubleshooting section
- Review Cloudflare and NGINX logs
- Ensure all prerequisites are met
- Verify environment variables are set correctly
PocketFast - Deploy PocketBase instances at lightning speed! ⚡