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:1
Build for production
Create the production build:
2
Upload to server
Transfer the
dist/ directory to your VPS:3
Configure systemd service
Create a systemd service file at
/etc/systemd/system/pb-ext.service:4
Enable and start service
Binary Optimization
The production build uses Go linker flags to reduce binary size:flag
Strip symbol table and debug information
flag
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:1
Upload new binary
2
Backup current binary
3
Replace binary
4
Reload service
5
Verify deployment
Check health endpoint:
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
Next Steps
Frontend Configuration
Configure SvelteKit and static file serving
Environment Setup
Configure ports, data directories, and environment variables