gary.info

here be dragons

How to Install Pocketbase on Digital Ocean

pocketbase-deploy.md

How To Install PocketBase on Digital Ocean

Prerequisites

  • A Digital Ocean account with an Ubuntu droplet (even the smallest $4 option works)
  • Basic knowledge of using the command line and SSH
  • A domain or subdomain (optional, for accessible URL with SSL)
  • Steps

  • Spin up a Digital Ocean droplet
  • - Select a standard Ubuntu droplet; any size works for testing

  • Download the Linux AMD64 binary
  • - Visit the PocketBase releases page (e.g., https://github.com/pocketbase/pocketbase/releases) - Download the latest linuxamd64 zip file (e.g., pocketbase0.8.0linuxamd64.zip)

  • Extract and upload the binary to your droplet
  • - Unzip the downloaded file on your local machine; it will produce two files: LICENSE and the executable “pocketbase” - Use rsync (or your preferred upload method) to transfer the binary to your droplet directory. For example: • rsync -avz -e ssh /local/path/to/pocketbase root@YOURDROPLETIP:/root/pb - The example above uploads the binary into the /root/pb directory on your droplet.

  • Create a systemd service to run PocketBase continually
  • - Open or create a new service file: • sudo vi /lib/systemd/system/pocketbase.service - Paste in the following content (replace yourdomain.com with your actual domain or subdomain):

    -------------------------------------------
         [Unit]
         Description = PocketBase Service
         [Service]
         Type           = simple
         User           = root
         Group          = root
         LimitNOFILE    = 4096
         Restart        = always
         RestartSec     = 5s
         StandardOutput = append:/root/pb/errors.log
         StandardError  = append:/root/pb/errors.log
         ExecStart      = /root/pb/pocketbase serve --http="yourdomain.com:80" --https="yourdomain.com:443"
         [Install]
         WantedBy = multi-user.target
         -------------------------------------------
  • Save and close the file.
  • - Enable and start the service: • sudo systemctl enable pocketbase.service --now

  • Assign a readable URL
  • - Instead of using an IP address, point your domain/subdomain to the droplet’s IP by configuring DNS via Digital Ocean’s networking tools (see DigitalOcean docs for adding domains) - PocketBase’s built-in HTTPS handling (via Let’s Encrypt) will work when your actual domain name is used in the service config.

  • Backup your PocketBase data
  • - PocketBase stores data in the pbdata directory (by default in /root/pb/pbdata/) - For regular backups, consider using a tool like rclone combined with a cron job to periodically sync your pb_data folder to backup storage (such as DO Spaces) - Alternatively, tools like Litestream (for SQLite backups) can be explored

    Tips

  • Make sure to leave SSH (port 22) open when configuring UFW/firewall rules. For example: sudo ufw allow 22/tcp
  • Although some may suggest using nginx or Apache as a reverse proxy, PocketBase includes its own HTTP/HTTPS server with automated certificate provisioning; you don’t need an additional web server for basic setups.
  • Test your installation locally before deploying to production by running:
  • • ./pocketbase serve This will start a local server on 127.0.0.1:8090 for exploration.

    Next Steps

  • Monitor the logs in /root/pb/errors.log to catch any issues early
  • Experiment with PocketBase features locally and adjust your production configuration as needed
  • Enhance security (e.g., update system packages, restrict file permissions) for a production environment