Forked from pocketbase/pocketbase
Features
- ✅ PostgresSQL (v17+) support
- ✅ Support horizontal scaling
- ✅ Realtime events works normally with horizontal scaling
- ✅ 100% test case pass rate across total 4701 unit tests
- ✅ Fully compatible with latest PocketBase SDKs/Docs
Get Started
Everything is the same as the original PocketBase, except that an additional environment variable POSTGRES_URL is required.
cp .env.example .env
make startDeploy with Docker
-
Start PostgresSQL:
docker run -d \ --name postgres \ -p 5432:5432 \ -e POSTGRES_USER=user \ -e POSTGRES_PASSWORD=pass \ -v ./pg_data:/var/lib/postgresql/data \ postgres:alpine
-
Start Moonbase (Don't use @latest tag, use a specific version in production)
docker run -d \ --network=host \ --name pocketbase \ -v ./pb_data:/data \ -e PB_HTTP_ADDR=127.0.0.1:8090 \ -e PB_DATA_DIR="/data" \ -e POSTGRES_URL="postgres://user:pass@127.0.0.1:5432/postgres?sslmode=disable" \ ghcr.io/fondoger/pocketbase:latest
-
Get admin password reset link
docker logs -f pocketbase
Available Environment Variables
| Environment Variable | Description | Default |
|---|---|---|
POSTGRES_URL |
PostgresSQL connection URL (required) | required |
POSTGRES_DATA_DB |
Database name for the PocketBase data | pb-data |
POSTGRES_AUX_DB |
Database name for the PocketBase logs data | pb-auxiliary |
PB_DATA_DIR |
Directory to store the PocketBase data | ./pb_data |
PB_PUBLIC_DIR |
Directory to store the public files | ./pb_public |
PB_HOOKS_DIR |
Directory to store the custom hooks | ./pb_hooks |
PB_REALTIME_BRIDGE |
Enable/Disable the realtime bridge. Disable it if you don't need horizontal scaling or don't need realtime feature. | true |
PB_HTTP_ADDR |
TCP address to listen for the HTTP server | 127.0.0.1:8090 if no domain specified |
PB_HTTPS_ADDR |
TCP address to listen for the HTTPS server | - |
PB_PATH_PREFIX |
URL path prefix for the HTTP server (Useful when reuse same domain for diffrent sites behind nginx) | - |
PB_ALLOWED_ORIGINS |
Comma separated list of allowed CORS origins | * (all origins) |
Limitations
- Local file system is not synced across multiple instances.
You need to add a S3 storage account if you are deploying multiple instances and need the file upload feature.
- The built-in SQLite Backup feature is not supported
PostgresSQL have many mature and stable backup solutions. Eg:
pg_dump,docker-pg-backup,postgres-backup-s3.
Disclaimer
I don't want to create another fork of PocketBase, but I really need PostgresSQL support for my project. The eventual goal is to merge this code back into the main PocketBase repository.
If you want to contribute, please first go to pocketbase/pocketbase. This repository only handles the bugs related to PostgresSQL.