---
title: Deploy PocketBase with AI on Blossom
url: "/deploy/pocketbase/"
canonical_url: https://blossom88.com/deploy/pocketbase/
markdown_url: https://blossom88.com/deploy/pocketbase.md
summary: Deploy PocketBase with AI on Blossom. Build a small application backend with
  SQLite, user authentication, realtime records, and persistent file uploads.
categories:
- deployment
- backend
stack:
- Go
- SQLite
---

# Deploy PocketBase with AI on Blossom

[PocketBase](https://pocketbase.io/) is a lightweight backend for small apps
and prototypes. It combines a database, user authentication, realtime
subscriptions, and file storage.

## Ask Your Agent

> **Ask your AI agent:** Deploy PocketBase on Blossom and help me connect my app.
>
> Follow this guide: https://blossom88.com/deploy/pocketbase/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## Your Backend Setup

| Part | Purpose |
|---|---|
| PocketBase | Serves the API and administrator dashboard |
| Persistent Volume | Keeps the SQLite database, settings, and uploaded files |

The dashboard at `/_/` stays behind Blossom Account access and a separate
PocketBase administrator login. Your app uses the public API with PocketBase
authentication and collection rules.

<details class="optional-reading" markdown="1">
<summary>Deployment setup and commands</summary>

Your agent checks the current CLI help and PocketBase's
[deployment requirements](https://pocketbase.io/docs/going-to-production/),
then selects a compatible maintained release. PocketBase does not publish an
official Docker image. We used the maintained
[muchobien community image](https://github.com/muchobien/pocketbase-docker),
which packages the upstream binary. Review its current build and pin a
multi-architecture image index compatible with your Location.

    blossom profile:show
    blossom app:create --data '{"app":{"name":"pocketbase"}}'

The agent writes environment.yml using the returned App ID:

```yaml
environment:
  app_id: app-100
  name: production
  source_type: prebuilt_image
  prebuilt_image: <maintained image pinned by your agent>
  access_mode: members
  access_public_paths:
    - /api/*
```

    blossom environment:create --data environment.yml

Only API requests bypass the Blossom access gate. PocketBase must enforce its
own authentication and access rules, including those for administrator APIs.
Keep user and superuser tokens out of frontend source and logs; browser apps
should receive only their signed-in user's token.

The agent writes service.yml with resources and Volume size suited to your
workload. For the community image above, the relevant settings are:

```yaml
service:
  environment_id: environment-100
  name: web
  entrypoint: /usr/local/bin/entrypoint.sh
  command: --encryptionEnv PB_ENCRYPTION_KEY
  port: 8090
  publicly_exposed: true
  desired_size: 1
  health_check:
    enabled: true
    kind: http
    path: /api/health
  storage:
    enabled: true
    size_gib: <size selected by your agent>
    mount_path: /pb_data
    availability: shared
```

Generate a random 32-character `PB_ENCRYPTION_KEY` and keep it stable in a
private .env.production file outside the application repository. The image
can bootstrap a superuser through `PB_ADMIN_EMAIL` and `PB_ADMIN_PASSWORD`.
After the first login, remove those two bootstrap variables from the runtime
file and push with `--prune`; retain the encryption key and any other runtime
settings. This avoids resetting the account's password at each startup.
Save the administrator login privately.

    blossom env_var:push --environment environment-100 --file .env.production
    blossom service:create --data service.yml
    blossom environment:deploy --id environment-100 --follow
    blossom environment:show --id environment-100

After removing the bootstrap variables:

    blossom env_var:push --environment environment-100 --file .env.production --prune
    blossom environment:deploy --id environment-100 --follow

Configure SMTP before relying on verification and password-reset emails.
Enable PocketBase's rate limiter and configure trusted proxy headers for the
actual ingress path. Check current upstream guidance before upgrades;
PocketBase is pre-1.0 and may require manual migration steps.

</details>

## Connect Your App

Create a collection, sign up two users, and give each user access to their
own records. Add a protected file field when uploads should be private.

![PocketBase showing owner-scoped tasks and file attachments.](/deploy/assets/images/pocketbase/tasks.webp)

<details class="optional-reading" markdown="1">
<summary>Access rules, updates, and backups</summary>

Use the [JavaScript SDK](https://pocketbase.io/docs/how-to-use/) or REST
API to connect your frontend. Check the current
[collection-rule syntax](https://pocketbase.io/docs/api-rules-and-filters/)
before configuring permissions. In our example, each task has an `owner`
relation to the users collection:

| Operation | Rule |
|---|---|
| List, view, delete | `@request.auth.id != "" && owner = @request.auth.id` |
| Create | `@request.auth.id != "" && @request.body.owner = @request.auth.id` |
| Update | `@request.auth.id != "" && owner = @request.auth.id && @request.body.owner:changed = false` |

Restrict each user's own account fields too. Allow public signup only when
your application needs it. Mark private file fields **Protected** and use
PocketBase's short-lived file tokens; a private record alone does not make an
ordinary file field private. Check reads, writes, file downloads, and realtime
subscriptions with a second user and without a login. Never ship a superuser
token to a client application.

Keep one active Container for the SQLite database. S3-compatible file storage
is optional, but SQLite still needs a Volume. This is a single-writer backend;
Container replacement includes a brief interruption.

    blossom service:show --id service-100
    blossom volume:list
    blossom environment:deploy --id environment-100 --follow

Keep the Volume and encryption key across updates. Sign in again, read an
existing record, download its protected attachment, and create a new record
after replacement. Retain schema migrations alongside your app's source.

Use [Blossom Volume backups](/docs/reference/cli/backup/create/) or PocketBase's
native backup feature, and keep copies outside the source Volume. Native
PocketBase backups exclude files already stored in S3. Test a restore before
relying on a backup for important data.

</details>

## What You Get

- A backend API with user authentication and realtime subscriptions
- A private administrator dashboard for collections and access rules
- SQLite records and uploaded files kept across Container replacements
