Skip to main content

PocketBase on Ubuntu

This guide provides detailed instructions to set up PocketBase on your Oracle Cloud Ubuntu instance, including configuring email for user registration and addressing the need for a domain name. It assumes you have an Oracle Cloud Ubuntu instance ready and excludes Flutter-related changes, as requested.

Prerequisites

  • Oracle Cloud Ubuntu instance (e.g., Ubuntu 22.04) with a public IP address.
  • (Optional but recommended) A domain name with DNS configured to point to your instance’s public IP. (you can work with IP also)
  • SSH access to your instance.
  • A third-party SMTP service account (e.g., MailerSend, Brevo, SendGrid, Mailgun, AWS SES or Good Old GMAIL) for email functionality.

Step 1: Download PocketBase

  1. Get link for here - https://github.com/pocketbase/pocketbase/releases
    wget https://github.com/pocketbase/pocketbase/releases/download/v0.29.1/pocketbase_0.29.1_linux_amd64.zip

Step 2: Create Work Directory

  1. Create working drectory and unzip the content
    mkdir pb
    cd pb
    unzip pocketbase_0.29.1_linux_amd64.zip

Step 3: Make Executable

  1. Make the pocketbase executable runnable:
    chmod +x pocketbase

Step 4: Configure Oracle Cloud Security Lists

  1. Ensure your instance allows incoming traffic on ports 80 (HTTP) and 443 (HTTPS).
  2. In the Oracle Cloud Console:
    • Go to Compute > Instances.
    • Select your instance.
    • Under Resources, click Virtual Cloud Network > Security Lists.
    • Add two ingress rules:
      • Protocol: TCP
      • Source CIDR: 0.0.0.0/0 (or restrict as needed)
      • Destination Port Range: 80 (for HTTP)
      • Repeat for port 443 (for HTTPS).
  3. Save the changes.
  4. Enable port in firewall on Ubuntu - Check below info

Step 5: Start PocketBase

  1. Start PocketBase with your domain or IP:
    • With a domain (recommended for production):

      ./pocketbase serve yourdomain.com

      Replace yourdomain.com with your domain name. This enables HTTPS with Let’s Encrypt.

    • With IP address (for testing, no HTTPS):

      ./pocketbase serve YOUR_SERVER_IP

      Replace YOUR_SERVER_IP with your instance’s public IP.

  2. Note: Running as root allows binding to ports 80 and 443. For non-root users, see Step 7.

Step 6: Access the Admin Dashboard

  1. Open a web browser and navigate to:
    • http://YOUR_SERVER_IP:8090/_/ (if using IP).
    • https://yourdomain.com/_/ (if using a domain).
  2. Follow the prompts to create your first superuser account (email and password).

Step 7: (Optional) Set Capabilities for Non-Root Users

  1. To run PocketBase as a non-root user (for security), set capabilities to allow binding to privileged ports:

    sudo setcap 'cap_net_bind_service=+ep' /root/pb/pocketbase
  2. Create a non-root user (if not already present) and adjust permissions:

    adduser pocketbase
    chown -R pocketbase:pocketbase /root/pb

Step 8: Configure Email for User Registration

  1. Log in to the Admin Dashboard (http://YOUR_SERVER_IP:8090/_/ or https://yourdomain.com/_/).
  2. Go to Settings > Mail settings.
  3. Configure SMTP settings using a third-party service. Example for MailerSend:
    • Host: smtp.mailersend.com
    • Port: 465
    • Encryption: TLS
    • Username: Your MailerSend API key
    • Password: (Leave blank for API key-based authentication)
  4. Save the settings.
  5. Test email functionality by creating a test user in the Users collection and verifying that registration emails are sent.
info

For GMAIL: you will need a App Password which is available only after enabling 2F Factor Auth

Step 9: (Optional) Set Up Systemd for Persistent Running

  1. Create a Systemd service file to ensure PocketBase runs continuously:

    sudo nano /lib/systemd/system/pocketbase.service
  2. Add the following content:

    [Unit]
    Description=PocketBase Service
    After=network.target

    [Service]
    User=root
    WorkingDirectory=/pb
    ExecStart=/pb/pocketbase serve yourdomain.com
    Restart=always
    RestartSec=10
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=pocketbase
    Environment=PB_PUBLIC_URL=https://yourdomain.com

    [Install]
    WantedBy=multi-user.target

    Replace yourdomain.com with your domain or YOUR_SERVER_IP if using the IP address.

    info

    Relative path to the pocketbase executabe will not work so use full path

  3. Save and exit (Ctrl+O, Enter, Ctrl+X).

  4. Reload Systemd and enable the service:

    sudo systemctl daemon-reload
    sudo systemctl enable pocketbase.service
    sudo systemctl start pocketbase

Step 10: Verify Setup

  1. Access your PocketBase instance via the browser:
    • http://YOUR_SERVER_IP:8090/_/ (or https://yourdomain.com/_/).
  2. Test user registration:
    • Create a new user in the Users collection via the Admin Dashboard.
    • Verify that registration emails are sent and received.
  3. Ensure authentication works by logging in with a test user.

Additional Notes

  • Domain Name: A domain is recommended for production to enable HTTPS with Let’s Encrypt, ensuring secure connections. Without a domain, use the IP address for testing, but HTTPS won’t be available, which may impact security.
  • Email Deliverability: Use a reliable SMTP service (e.g., MailerSend, SendGrid) to ensure registration and password recovery emails are delivered.
  • Security: Enable Multi-Factor Authentication (MFA) for superusers in the Dashboard (Settings > Superusers) for added security.
  • Backups: Regularly back up the pb_data directory (located in /root/pb) or use PocketBase’s built-in backup APIs (Settings > Backups).
  • Oracle Cloud Free Tier: The free tier provides limited resources (e.g., 20 GB storage, 1 vCPU, 1 GB RAM for AMD instances). Ensure your data and traffic fit within these limits.
  • File Storage: By default, files are stored in pb_data/storage. If you need more storage, configure Oracle Cloud Object Storage (20 GB free) as an S3-compatible backend.

Troubleshooting

  • Port Issues: If you can’t access PocketBase, verify that ports 80 and 443 are open in Oracle Cloud’s security lists.

  • Email Not Sending: Double-check SMTP settings and ensure your SMTP service is correctly configured.

  • Service Not Starting: Check the Systemd service status:

    sudo systemctl status pocketbase

Resources

  • PocketBase Official Documentation
  • PocketBase GitHub Releases
  • Oracle Cloud Networking Guide