Pocketbase

Pocketbase is a self-hosted Backend as a Service with a functionality similar to Google Firebase or Supabase. It provides APIs for a managed SQLite database, user authentication, file storage and more. As most applications written in Go it’s easy to install.


Note

For this guide you should be familiar with the basic concepts of

License

Pocketbase is licensed under the MIT license

Installation

Download the latest release and extract it to your binary folder:

[isabell@stardust ~]$ wget -O pocketbase.zip https://github.com/pocketbase/pocketbase/releases/download/v0.22.8/pocketbase_0.22.8_linux_amd64.zip
[...]
Saving to: ‘pocketbase.zip’

100%[====================================================================================================================================================>] 14,321,393  23.1MB/s   in 0.6s

2024-04-11 11:22:32 (23.1 MB/s) - ‘pocketbase.zip’ saved [14321393/14321393]
[isabell@stardust ~]$ unzip pocketbase.zip pocketbase -d ~/bin/
Archive:  pocketbase.zip
  inflating: /home/isabell/bin/pocketbase
[isabell@stardust ~]$

It should be added to your path automatically. Now test if it works:

[isabell@stardust ~]$ pocketbase -v
pocketbase version 0.22.8
[isabell@stardust ~]$

Setup Supervisord

First create a folder where all data is stored:

[isabell@stardus ~]$ mkdir ~/pocketbase
[isabell@stardus ~]$

Warning

To modify this specific running instance of Pocketbase (e.g. updating, user management), all pocketbase commands must be executed in the folder you just created!

Now, create a configuration file ~/etc/services.d/pocketbase.ini:

[program:pocketbase]
directory=%(ENV_HOME)s/pocketbase
command=pocketbase serve --http :8090
autostart=yes
autorestart=yes
startsecs=60

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

Note

Pocketbase is running on port 8090.

To make the application accessible from the outside, configure a web backend:

[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$

Creating an admin user

First, find out your domain name:

[isabell@stardust ~]$ uberspace web domain list
isabell.uber.space
[isabell@stardust ~]$

To create an admin user open https://isabel.uber.space/_/ (mind the underscore in the URL) and follow through the instructions of the installer. Alternatively you can use the admin CLI via pocketbase admin to create, delete and update admin users.

Updates

Note

Check the update documentation or releases page regularly to stay informed about the newest version.

To update the current executable you have two choices:

  • Repeat the steps in the Installation section above.

  • Run the built-in updater using pocketbase update inside ~/pocketbase

After updating, tell supervisord to restart the service:

[isabell@stardust ~]$ supervisorctl restart pocketbase
SERVICE: stopped
SERVICE: started
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

Breaking changes

Pocketbase is still in early development. Hence, a new realease might introduce breaking changes. While updating you might need to run a migration using pocketbase migrate. Please refer to the documentation.


Tested with Pocketbase 0.22.8, Uberspace 7.15.14

Written by: bliepp <https://github.com/bliepp>