Skip to main content

Production Build

Create an optimized production build using the pb-cli toolchain:
This command:
  • 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
These flags typically reduce binary size by 20-30% without affecting runtime performance.

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:
Schedule with cron:

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

  • Run pb-cli --production successfully
  • Test OpenAPI specs with --validate-specs-dir
  • Review and test frontend build
  • Verify environment variables are configured
  • Backup current production database
  • SSL/TLS certificates configured
  • Firewall rules in place
  • Service runs as non-root user
  • Database file permissions restricted (0600)
  • Admin panel behind authentication
  • 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