Skip Navigation

Scott Spence

Multi-instance PocketBase setup

• 4 min read
Hey! Thanks for stopping by! Just a word of warning, this post is 2 years old, . If there's technical information in here it's more than likely out of date.

I’ve been playing around with Hetzner Cloud for a while now, mainly setting up this site on it using Coolify but it got me thinking about using it for other things too.

I’ve used PocketBase before for other projects and documented it for use with Fly.io. This time round, I’m using a Hetzner VPS.

Now, the PocketBase binary is like 38mb so using a a VPS with a 40gb SSD is a bit overkill for the small amount of data I’m storing for the toy projects I’m working on. I have several small projects that I want to use PocketBase for, so, instead of setting up a new box for each one, I thought I’d try to set up a multi-instance setup.

Pre-requisites

I’ve already done this, I’m documenting for future me. If you’re thinking about doing something similar bear in mind that I already have a VPS box set up on Hetzner and some domains (on Cloudflare) that I’m going to proxy to.

Shiny new box

Aight, so, new Hetzner box, I’m going to SSH into it and update it. Just a side note here I’ve started using the 1Password CLI for SSH keys and it is really handy.

Update the box:

1apt update
2apt upgrade -y
3apt update && apt upgrade -y && apt autoremove -y

Yes, I’m not using a sudoers account! Rawdogging it as root. If you’re interested I go through Setting up my VPS on Hetzner which set’s up a user account on the sudoers list and removes the root user.

Download PocketBase

Ok, so I want to download PocketBase to the box, I’ll get the latest PocketBase binary listed on the PocketBase docs I’m on ARM64 so I’ll get that with wget.

1wget https://github.com/pocketbase/pocketbase/releases/download/v0.22.19/pocketbase_0.22.19_linux_arm64.zip

Unzip the binary, I’m going to use unzip, which isn’t installed by default on Ubuntu, so I’ll install it:

1apt install unzip

Create project directories

I’m going to create a couple of directories for the projects I’m setting up, rinku-cloud and dope-devs.

1mkdir {rinku-cloud,dope-devs}

Then move the PocketBase zip file into the dope-devs directory and unzip it.

1mv pocketbase_0.22.19_linux_arm64.zip dope-devs/
2cd dope-devs/
3unzip pocketbase_0.22.19_linux_arm64.zip

Same thing for the rinku-cloud directory.

1mv pocketbase_0.22.19_linux_arm64.zip ../rinku-cloud/
2cd ../
3cd rinku-cloud/
4unzip pocketbase_0.22.19_linux_arm64.zip

Set up services

I want to set up two services to run on localhost for the two projects and assign a port for each. I’ll just go through the process of setting up one service, NOTE that for the other service I’ll need to change the port number.

Create the service file using nano:

1nano /etc/systemd/system/pocketbase-rinku-cloud.service

Then edit the file and add in the service details:

1[Unit]
2Description=PocketBase Rinku Cloud
3After=network.target
4
5[Service]
6Type=simple
7User=root
8Group=root
9ExecStart=/root/rinku-cloud/pocketbase serve --http="127.0.0.1:8090"
10WorkingDirectory=/root/rinku-cloud
11Restart=on-failure
12
13[Install]
14WantedBy=multi-user.target

Write out the file, save it and exit. I’ll then enable the service, start it and check the status.

1systemctl enable pocketbase-rinku-cloud.service
2systemctl start pocketbase-rinku-cloud.service
3systemctl status pocketbase-rinku-cloud.service

I get an output looking something like this:

1● pocketbase-rinku-cloud.service - PocketBase Rinku Cloud
2     Loaded: loaded (/etc/systemd/system/pocketbase-rinku-cloud.service; enabled; preset: enabled)
3     Active: active (running) since Sat 2024-08-17 19:46:40 UTC; 1min 4s ago
4   Main PID: 708 (pocketbase)
5      Tasks: 8 (limit: 4433)
6     Memory: 44.6M (peak: 44.9M)
7        CPU: 619ms
8     CGroup: /system.slice/pocketbase-rinku-cloud.service
9             └─708 /root/rinku-cloud/pocketbase serve --http=127.0.0.1:8090

Install and config Caddy

I’m going to go to the Caddy documentation for Ubuntu and copy pasta the commands for installing Caddy.

1sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
2curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
3curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
4sudo apt update
5sudo apt install caddy

Change directory into the etc folder and create a Caddyfile.

1cd /etc/caddy/
2nano Caddyfile

In the Caddyfile I’m going to add in the two domains I’m proxying NOTE that I have already added an A record for pb in my DNS records for the domains that points back to my Hetzner IP address.

1pb.rinku.cloud {
2  reverse_proxy localhost:8090
3}
4
5pb.dopedevs.icu {
6  reverse_proxy localhost:8091
7}

Write out the file, save it and exit. I’ll then enable the Caddy service, start it and check the status.

1systemctl enable caddy
2systemctl start caddy
3systemctl status caddy

Login to PocketBase

Now my services are running I can now login to PocketBase for each of the projects and get them configured how I want.

Conclusion

I’ve now got a multi-instance PocketBase setup running on Hetzner Cloud with Caddy as a reverse proxy.

There's a reactions leaderboard you can check out too.

Sign up for the newsletter

Want to keep up to date with what I'm working on?

Join other developers and sign up for the newsletter.

I care about the protection of your data. Read the Privacy Policy for more info.

Copyright © 2017 - 2026 - All rights reserved Scott Spence