mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem
Following the Compute "copy as AI prompt" snippet word for word fails
against the current CLI (3.2.0):
1. `size = "2gb-1vcpu"` → `UnknownComputeSizeError`. config.toml takes
`2gb` / `4gb`; the CLI maps those to the API's `2gb-1vcpu` itself
(`apiSizeFor` in `apps/cli/src/shared/compute/compute-runtimes.ts`).
2. Nothing says to enable `[experimental] compute = true` /
`SUPABASE_EXPERIMENTAL_COMPUTE=1`, so the CLI fails with `Unknown
subcommand "compute"`. SupaSquad testers have hit the same error.
3. For the Dockerfile runtime the prompt read "a Dockerfile entrypoint
(Dockerfile)" and never mentioned the port.
5. Every prompt asked for an HTTP "Hello, world!" server, including
private instances. Private exposure has no inbound network access: a
private instance is a background worker (for example, a loop polling a
pgmq queue) and doesn't listen on any port. Deploying an HTTP server as
private is what produced the `listen tcp :8080: bind: address already in
use` error I hit. The call snippets also sent an `Authorization` header,
but public instances don't verify API keys.
4. The instance CLI commands suggest `supabase compute pull` (doesn't
exist) and `supabase compute logs --follow` (deprecated; there's no
`--follow` on the replacement).
I hit these deploying a Dockerfile hello-world from the snippet.
## Solution
- Write the CLI size (`2gb`) into the config.toml block. The API size
still drives the `# 2 GB · 1 vCPU` comment, and the deploy dialog is
unchanged.
- The prompt says to set `compute = true` under `[experimental]`, and to
link the project before `push`. The CLI snippet exports
`SUPABASE_EXPERIMENTAL_COMPUTE=1`, and the config.toml snippet has a
comment about it.
- The prompt branches on access. Public: serve plain HTTP on `$PORT`
(defaults to 8080) and add your own auth if needed. Private: run a
background worker and don't start an HTTP server. Dockerfile prompts say
"a Dockerfile" instead of the garbled entrypoint.
- Overview tab: "Listening port" shows `$PORT → 8080` for public and
"None (background worker)" for private, and "How to call" only renders
for public instances. The JS and Python call snippets drop the
`Authorization` header.
- The deploy dialog's access description explains both modes instead of
mentioning a publishable key.
- Drop `pull` and switch logs to `supabase logs --remote --service
compute --resource <name>` in both the overview and logs tabs.
Tests cover each of these in `computeInstanceSnippets.test.ts`.
Not in this PR: Studio's `RUNTIMES.node.entrypoint` is `node index.js`,
while the CLI scaffolds `index.mjs` exporting `{ fetch }` (same for deno
`main.ts`). The node/deno prompt may need a similar pass.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
268 lines
9.2 KiB
TypeScript
268 lines
9.2 KiB
TypeScript
import { ReactNode } from 'react'
|
|
import { Badge } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { InfoTooltip } from 'ui-patterns/info-tooltip'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import {
|
|
PageSection,
|
|
PageSectionContent,
|
|
PageSectionDescription,
|
|
PageSectionMeta,
|
|
PageSectionSummary,
|
|
PageSectionTitle,
|
|
} from 'ui-patterns/PageSection'
|
|
|
|
import { COMPUTE_REGION_LABEL, LISTENING_PORT } from '../Compute.constants'
|
|
import type { ComputeInstance } from '../Compute.types'
|
|
import { formatSize, getRuntimeMeta } from '../Compute.utils'
|
|
import { ComputeInstanceCommandLine } from '../ComputeInstanceCommandLine'
|
|
import { buildComputeInstanceCliCommands } from '../computeInstanceSnippets'
|
|
import {
|
|
COMPUTE_INSTANCE_CALL_TABS,
|
|
ComputeInstanceSnippetTabs,
|
|
} from '../ComputeInstanceSnippetTabs'
|
|
import { RuntimeBadge } from '../RuntimeBadge'
|
|
import { CLI_NAME } from '@/lib/constants/compute'
|
|
|
|
interface ComputeInstanceOverviewTabProps {
|
|
instance: ComputeInstance
|
|
}
|
|
|
|
const ComputeInstanceCount = ({
|
|
label,
|
|
value,
|
|
tooltip,
|
|
}: {
|
|
label: string
|
|
value: number
|
|
tooltip: ReactNode
|
|
}) => (
|
|
<div className="flex flex-col gap-1 px-5 py-4">
|
|
<span className="flex items-center gap-1.5 text-sm text-foreground-light">
|
|
{label}
|
|
<InfoTooltip side="top" className="max-w-56">
|
|
{tooltip}
|
|
</InfoTooltip>
|
|
</span>
|
|
<span className="text-2xl tabular-nums text-foreground">{value}</span>
|
|
</div>
|
|
)
|
|
|
|
const SettingsRow = ({
|
|
label,
|
|
children,
|
|
isFirst,
|
|
}: {
|
|
label: string
|
|
children: ReactNode
|
|
isFirst?: boolean
|
|
}) => (
|
|
<div
|
|
className={`flex items-center justify-between px-4 py-3 ${
|
|
isFirst ? '' : 'border-t border-default'
|
|
}`}
|
|
>
|
|
<span className="text-sm text-foreground-light">{label}</span>
|
|
<span className="text-sm text-foreground">{children}</span>
|
|
</div>
|
|
)
|
|
|
|
export const ComputeInstanceOverviewTab = ({ instance }: ComputeInstanceOverviewTabProps) => {
|
|
const runtime = getRuntimeMeta(instance.runtime)
|
|
const commands = buildComputeInstanceCliCommands(instance.name)
|
|
|
|
return (
|
|
<PageContainer size="small">
|
|
{instance.buildState === 'failed' && (
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<Admonition type="destructive" title="This instance failed to build">
|
|
<div className="space-y-3">
|
|
<p>{instance.stateReason ?? 'The build did not complete.'}</p>
|
|
<ComputeInstanceCommandLine
|
|
comment="Redeploy after fixing the build"
|
|
command={`supabase ${CLI_NAME} push ${instance.name}`}
|
|
/>
|
|
</div>
|
|
</Admonition>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
|
|
{instance.instancesError !== undefined && (
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<Admonition type="warning" title="Instances reported an error">
|
|
{instance.instancesError}
|
|
</Admonition>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Instances</PageSectionTitle>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
{instance.instances === undefined ? (
|
|
<p className="text-sm text-foreground-light">
|
|
No instances are running for this instance yet.
|
|
</p>
|
|
) : (
|
|
<div className="space-y-3">
|
|
<p className="text-sm text-foreground-light">
|
|
<span className="tabular-nums text-foreground">{instance.instances.ready}</span> of{' '}
|
|
<span className="tabular-nums text-foreground">{instance.instances.declared}</span>{' '}
|
|
instances ready
|
|
</p>
|
|
<div className="grid grid-cols-2 divide-x divide-y rounded-md border border-default bg-surface-100 sm:grid-cols-4 sm:divide-y-0">
|
|
<ComputeInstanceCount
|
|
label="Instances"
|
|
value={instance.instances.declared}
|
|
tooltip="The number of instances you configured for this deployment."
|
|
/>
|
|
<ComputeInstanceCount
|
|
label="Live"
|
|
value={instance.instances.live}
|
|
tooltip="Instances currently running."
|
|
/>
|
|
<ComputeInstanceCount
|
|
label="Ready"
|
|
value={instance.instances.ready}
|
|
tooltip="Instances passing health checks and serving requests."
|
|
/>
|
|
<ComputeInstanceCount
|
|
label="Stale"
|
|
value={instance.instances.stale}
|
|
tooltip="Instances from a previous deployment, being replaced."
|
|
/>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Container</PageSectionTitle>
|
|
<PageSectionDescription>
|
|
The runtime image and entrypoint resolved for this instance.
|
|
</PageSectionDescription>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<div className="rounded-md border border-default bg-surface-100">
|
|
<SettingsRow label="Runtime" isFirst>
|
|
<RuntimeBadge runtime={instance.runtime} />
|
|
</SettingsRow>
|
|
{instance.imageVersion !== undefined && (
|
|
<SettingsRow label="Version">
|
|
<span className="font-mono text-xs text-foreground-light">
|
|
{instance.imageVersion}
|
|
</span>
|
|
</SettingsRow>
|
|
)}
|
|
{runtime !== undefined && (
|
|
<SettingsRow label="Base image">
|
|
<span className="font-mono text-xs text-foreground-light">{runtime.baseImage}</span>
|
|
</SettingsRow>
|
|
)}
|
|
{runtime !== undefined && (
|
|
<SettingsRow label="Entrypoint">
|
|
<span className="font-mono text-xs text-foreground-light">
|
|
{runtime.entrypoint}
|
|
</span>
|
|
</SettingsRow>
|
|
)}
|
|
<SettingsRow label="Listening port">
|
|
<span className="font-mono text-xs text-foreground-light">
|
|
{instance.access === 'public'
|
|
? `$PORT → ${LISTENING_PORT}`
|
|
: 'None (background worker)'}
|
|
</span>
|
|
</SettingsRow>
|
|
</div>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Resources</PageSectionTitle>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<div className="rounded-md border border-default bg-surface-100">
|
|
<SettingsRow label="Size" isFirst>
|
|
{formatSize(instance.size)}
|
|
</SettingsRow>
|
|
<SettingsRow label="Instances">{instance.declaredInstances}</SettingsRow>
|
|
<SettingsRow label="Access">
|
|
{instance.access === 'public' ? (
|
|
<Badge variant="success">Public</Badge>
|
|
) : (
|
|
<Badge>Private</Badge>
|
|
)}
|
|
</SettingsRow>
|
|
<SettingsRow label="Region">
|
|
<span className="text-foreground-light">
|
|
{COMPUTE_REGION_LABEL} <span className="text-foreground-lighter">(locked)</span>
|
|
</span>
|
|
</SettingsRow>
|
|
</div>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
|
|
{instance.access === 'public' && (
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>How to call</PageSectionTitle>
|
|
<PageSectionDescription>
|
|
Call the instance over its gateway URL.
|
|
</PageSectionDescription>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<ComputeInstanceSnippetTabs
|
|
input={{
|
|
name: instance.name,
|
|
runtime: instance.runtime,
|
|
size: instance.size,
|
|
access: instance.access,
|
|
instances: instance.declaredInstances,
|
|
}}
|
|
tabs={COMPUTE_INSTANCE_CALL_TABS}
|
|
/>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Develop locally</PageSectionTitle>
|
|
<PageSectionDescription>
|
|
Manage this instance from the Supabase CLI.
|
|
</PageSectionDescription>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<div className="space-y-4 rounded-md border border-default bg-surface-100 p-4">
|
|
{commands.map((command) => (
|
|
<ComputeInstanceCommandLine
|
|
key={command.command}
|
|
comment={command.comment}
|
|
command={command.command}
|
|
/>
|
|
))}
|
|
</div>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
</PageContainer>
|
|
)
|
|
}
|