Production Build
Create an optimized production build using thepb-cli toolchain:
- Builds and optimizes frontend assets
- Generates OpenAPI specifications
- Compiles the server binary with optimization flags (
-ldflags="-s -w") - Creates a deployment-ready package in the
dist/directory
Custom Output Directory
Specify a custom output directory:Automated Deployment with pb-deployer
pb-deployer provides automated VPS deployment with zero-downtime updates, security hardening, and automated backup management.Installation
Features
Server Provisioning
Automated server setup with best practices
Security Hardening
SSL/TLS, firewall configuration, and security updates
Zero-Downtime
Rolling updates with health checks
Auto-Rollback
Automatic rollback on deployment failure
Systemd Integration
Service management and auto-restart
Backup Management
Automated backups of data and configurations
pb-deployer handles the entire deployment lifecycle, from initial server setup to ongoing updates and maintenance.
Manual VPS Deployment
For manual deployments, follow these steps:Binary Optimization
The production build uses Go linker flags to reduce binary size:Strip symbol table and debug information
Strip DWARF debugging information
SSL/TLS Configuration
Reverse Proxy with Nginx
Recommended approach for production:Let’s Encrypt
Obtain free SSL certificates:Zero-Downtime Updates
For manual zero-downtime deployments:Backup Strategies
Database Backups
PocketBase uses SQLite, making backups straightforward:Automated Backups with pb-deployer
pb-deployer includes built-in backup management with configurable retention policies and automated restoration.
Health Checks
Monitor your deployment:Production Checklist
Before Deployment
Before Deployment
- Run
pb-cli --productionsuccessfully - Test OpenAPI specs with
--validate-specs-dir - Review and test frontend build
- Verify environment variables are configured
- Backup current production database
Security
Security
- SSL/TLS certificates configured
- Firewall rules in place
- Service runs as non-root user
- Database file permissions restricted (0600)
- Admin panel behind authentication
Monitoring
Monitoring
- Systemd service enabled and running
- Log rotation configured
- Backup script scheduled
- Health check endpoint accessible
- Alerts configured for service failures