Overview
Sptfy.in requires configuration in two places:- Backend (VPS):
.envfile for PocketBase environment variables - Frontend (Cloudflare Pages): Build environment variables
Backend Configuration (PocketBase)
Environment Variables
The.env file in your ~/pb-docker directory configures the PocketBase backend.
Required Variables
Optional Maintenance Mode Variables
These are frontend environment variables (set in Cloudflare Pages, not in.env):
PUBLIC_MAINTENANCE_MODE=true→ Force maintenance mode ONPUBLIC_MAINTENANCE_MODE=false→ Follow scheduled window (auto-activates between SCHEDULED and END)PUBLIC_MAINTENANCE_MODE=off→ Force maintenance mode OFF
Docker Compose Configuration
Thedocker-compose.yml file defines the PocketBase container setup.
Key Configuration Options
8091:8090 - Maps host port 8091 to container port 8090. Change if port 8091 is already in use.
Persistent data directories:
./pb_data- Database files (SQLite)./pb_public- Public file storage./pocketbase/pb_hooks- Custom API hooks (JavaScript)./pocketbase/pb_migrations- Database migrations
Checks
/api/health every 60 seconds. Container marked unhealthy after 2 failed retries.Timezone for container. Change to your preferred timezone (e.g.,
America/New_York, Europe/London).Cloudflare Turnstile secret key (loaded from
.env file).Changing the Port
If port 8091 conflicts with another service:-
Edit
docker-compose.yml: -
Restart the container:
- Update your Nginx reverse proxy to use the new port (see Deployment).
Changing the Timezone
-
Edit
docker-compose.yml: -
Restart the container:
Frontend Configuration (Cloudflare Pages)
Required Environment Variables
Set these in Cloudflare Pages → Your Project → Settings → Environment Variables.Get this from Cloudflare Dashboard → Turnstile → Your Site → Site Key. This is the public key (safe to expose).
The public URL of your PocketBase instance. Must be HTTPS in production (set up via Nginx reverse proxy).
Build Configuration
Cloudflare Pages auto-detects SvelteKit. Default settings work, but you can customize:Sptfy.in uses pnpm for package management. If Cloudflare Pages doesn’t auto-detect pnpm, you may need to:
- Add a
.nvmrcfile with20(Node.js version) - Use build command:
npx pnpm install && npx pnpm build
PocketBase Admin Configuration
Admin Panel Access
Access the PocketBase admin panel at:- Local development:
http://127.0.0.1:8090/_/ - Production:
https://pbbase.sptfy.in/_/
Collections Configuration
Key collections in the database:users- User accounts (OAuth via Spotify)random_short- Short links (both random and custom slugs)analytics- Click analytics and trackingblocks- Blocked users/IPs
API Rules
PocketBase uses collection-level API rules. Important settings:- List/View Rules: Control who can read records
- Create Rules: Control who can create records
- Update Rules: Control who can modify records
- Delete Rules: Control who can delete records
The schema is defined in
pocketbase/pb_migrations/. Migrations run automatically on container start.Backup Configuration
PocketBase Built-in Backups
PocketBase supports automated backups to S3-compatible storage. Production setup uses Cloudflare R2 for backups:- Go to PocketBase Admin → Settings → Backups
- Configure S3 settings:
- Endpoint:
https://<account-id>.r2.cloudflarestorage.com - Bucket: Your R2 bucket name
- Region:
auto - Access Key: R2 access key ID
- Secret Key: R2 secret access key
- Endpoint:
- Set backup schedule (e.g., daily at 3 AM)
Manual Backups
Create a manual backup:Security Best Practices
Use strong secrets
- Use production Cloudflare Turnstile keys (not test keys)
- Set a strong PocketBase admin password
- Rotate secrets periodically
Enable HTTPS
Use Nginx with Let’s Encrypt SSL certificates (see Deployment)
Next Steps
- Database Setup - Configure PocketBase collections and data
- Deployment - Set up Nginx reverse proxy and Cloudflare Pages