Files
Jordi EnricandFrancesco Sansalvadore 509d80c9eb feat(studio): CLI deploy instructions for workers (FE-4191) (#49194)
## What

The surface that shows you how to deploy a worker from the CLI, plus the
product rename and the alpha framing.

- **Compute → Workers.** `PRODUCT_NAME` and `CLI_NAME` now say `Workers`
/ `workers`, so the sidebar, page title, command menu, and every
generated snippet match the CLI. One name, not two.
- **`DeployWorkerDialog`** — scaffold / configure / push, with copyable
`supabase workers` and `config.toml` snippets
- **`WorkersEmptyState`** — an `EmptyStatePresentational` with a
permission-gated deploy action
- **`AlphaNotice`** on the list page, and a **New** badge on the sidebar
entry (`Route.isNew`)
- **`WorkerSnippetTabs`** — CLI, `config.toml`, and curl/JS/Python calls
built from one worker shape. Reused by #49195.

Snippet URLs resolve from the project's `app_config.endpoint`
(`https://<project>/workers/v1/<name>`, the same shape as
`/functions/v1/`), and fall back to `[YOUR WORKER URL]` before settings
load rather than printing a wrong host.

## How to test

Only on the **Mockamaster** project in staging — it is the one project
in the alpha allow-list.

1. Staging dashboard → Mockamaster → **Workers** (the sidebar entry
carries a **New** badge)
2. **Deploy a worker** → step through the tabs; every snippet should
name the real worker URL, not a placeholder
3. Copy the cURL snippet and run it: expect `401`. Reaching a deployed
worker needs a second allow-list (`WORKERS_ALLOWED_PROJECTS` in
api-gateway `customer-router/wrangler.toml`), separate from the flag
that unlocks the dashboard.
4. Open a project with no workers to see the empty state

## Tests

`workerSnippets.test.ts` covers the generated output users copy: worker
URL in all three call snippets, the `[YOUR WORKER URL]` fallback, anon
vs service-role placeholder, empty-name fallback and trimming, runtime
default, and every `config.toml` field.

## Unverified copy

The dialog steps and the `supabase workers <sub>` subcommands come from
the original POC spec, not from the shipped CLI. Same for "Dockerfile,
Node.js and Deno supported" in the empty state — only Deno is confirmed
end to end. Worth a check by someone who knows the CLI surface.

Closes FE-4191

---------

Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
2026-08-25 15:38:57 +02:00

48 lines
1.6 KiB
TypeScript

export const PRODUCT_NAME = 'Workers'
export const CLI_NAME = 'workers'
export const WORKERS_CLI_DEPLOY = `supabase ${CLI_NAME} push`
export const WORKERS_SKILL_MARKDOWN = `# Supabase ${PRODUCT_NAME} — agent skill
Deploy and manage backend workers (microVMs) that run next to a Supabase project's Postgres.
## Deploy from config.toml
Add a block to \`supabase/config.toml\`:
\`\`\`toml
[${CLI_NAME}.embed]
runtime = "python" # node | deno | bun | python | dockerfile
size = "2gb-1vcpu" # 2gb-1vcpu | 4gb-2vcpu — fixed at deploy
access = "public" # public | private
instances = 1 # 1..10 per deploy; 100 cap per project
secrets = ["OPENAI_API_KEY"] # names only — values live in the Secrets API
\`\`\`
Then run:
\`\`\`bash
supabase ${CLI_NAME} new embed --runtime python
supabase ${CLI_NAME} push embed
\`\`\`
Config precedence: \`--flag\` > \`config.toml\` > interactive prompt > default.
## Conventions
- Workers under \`supabase/${CLI_NAME}/<name>/\` are auto-discovered; the folder name is the slug.
- \`entrypoint\` is inferred from the runtime (node index.js, deno run main.ts, python main.py, Dockerfile CMD).
- \`region\` is locked to us-west-2 at alpha — do not set it.
- Sizes are fixed at deploy time. To change size, delete the worker and redeploy.
## Manage
- \`supabase ${CLI_NAME} list\`
- \`supabase ${CLI_NAME} status <name>\`
- \`supabase ${CLI_NAME} logs <name> --follow\`
- \`supabase ${CLI_NAME} stop <name>\` # scale to zero (reversible)
- \`supabase ${CLI_NAME} start <name>\`
- \`supabase ${CLI_NAME} delete <name>\`
`