Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Enable and configure Cloudflare Sandboxes. Importing from `void/sandbox` enables
| `platformImage` | `string` | `cloudflare/debian-trixie` |
| `instanceType` | `string` | `lite` |

Supported sizes are `lite` and `standard-1` through `standard-4`. Native deploys build Dockerfiles with Docker; registry images must be digest-pinned references from the Cloudflare managed registry. Custom images must include the matching Sandbox SDK helper. For a local Dockerfile, supply `platformImage` when deploying to a managed platform. See [Sandboxes](../guide/sandboxes.md) for image setup and runtime examples.
Supported sizes are `lite`, `basic`, and `standard-1` through `standard-4`. Native deploys build Dockerfiles with Docker; registry images must be digest-pinned references from the Cloudflare managed registry. Custom images must include the matching Sandbox SDK helper. For a local Dockerfile, supply `platformImage` when deploying to a managed platform. See [Sandboxes](../guide/sandboxes.md) for image setup and runtime examples.

Sandbox requires [Workers Paid](https://dash.cloudflare.com/?to=/:account/workers/plans) and Containers access. Managed runtime tokens need Account / Containers: Edit and Account / Cloudchamber: Edit. See [Sandbox deployment](../guide/sandboxes.md#deployment).

Expand Down
2 changes: 1 addition & 1 deletion packages/void/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
},
"instanceType": {
"type": "string",
"enum": ["lite", "standard-1", "standard-2", "standard-3", "standard-4"],
"enum": ["lite", "basic", "standard-1", "standard-2", "standard-3", "standard-4"],
"description": "Cloudflare Container instance type."
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/void/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const VALID_DATABASE_CASINGS = new Set(['snake_case', 'camelCase']);
const MAX_WORKER_CPU_MS = 300000;
const VALID_SANDBOX_INSTANCE_TYPES = new Set<SandboxInstanceType>([
'lite',
'basic',
'standard-1',
'standard-2',
'standard-3',
Expand Down
8 changes: 7 additions & 1 deletion packages/void/src/runtime/sandbox/container.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Files, type FileOperationOptions } from '@cloudflare/sandbox';
import { DurableObject, RpcTarget } from 'cloudflare:workers';

export type SandboxInstance = 'lite' | 'standard-1' | 'standard-2' | 'standard-3' | 'standard-4';
export type SandboxInstance =
| 'lite'
| 'basic'
| 'standard-1'
| 'standard-2'
| 'standard-3'
| 'standard-4';
export type SandboxOptions = {
inactivityTimeoutMs?: number;
enableInternet?: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/void/src/sandbox/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const SANDBOX_MIGRATION_TAG = 'void-sandbox-v2';

export type SandboxInstanceType =
| 'lite'
| 'basic'
| 'standard-1'
| 'standard-2'
| 'standard-3'
Expand Down
16 changes: 16 additions & 0 deletions packages/void/test/unit/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,22 @@ describe('readConfig', () => {
expect(config.platformImage).toBe('cloudflare/debian-trixie');
});

it('reads sandbox basic instanceType', () => {
setup(
JSON.stringify({
sandbox: {
image: './Dockerfile.sandbox',
instanceType: 'basic',
},
}),
);
expect(readConfig(tmpDir).sandbox).toEqual({
image: './Dockerfile.sandbox',
instanceType: 'basic',
});
cleanup();
});

it('throws on invalid sandbox config', () => {
setup(JSON.stringify({ sandbox: { instanceType: 'huge' } }));
expect(() => readConfig(tmpDir)).toThrow('"sandbox.instanceType"');
Expand Down
2 changes: 1 addition & 1 deletion platform/packages/api/src/deploy/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export async function handleManifestOnlyDeploy(context: Context<ApiEnv>): Promis
((incomingManifest.sandbox.image !== 'cloudflare/debian-trixie' &&
!isSandboxRegistryImage(incomingManifest.sandbox.image)) ||
(incomingManifest.sandbox.instanceType !== undefined &&
!['lite', 'standard-1', 'standard-2', 'standard-3', 'standard-4'].includes(
!['lite', 'basic', 'standard-1', 'standard-2', 'standard-3', 'standard-4'].includes(
incomingManifest.sandbox.instanceType,
)))
) {
Expand Down
13 changes: 12 additions & 1 deletion platform/packages/api/test/integration/api-sandbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const SANDBOX_IMAGE_V1 =
function buildSandboxManifest(overrides?: {
image?: string;
containerName?: string;
instanceType?: string;
}): Record<string, unknown> {
return {
version: 3,
Expand All @@ -67,7 +68,7 @@ function buildSandboxManifest(overrides?: {
className: 'Sandbox',
containerName: overrides?.containerName ?? 'void-sandbox',
image: overrides?.image ?? SANDBOX_IMAGE_V1,
instanceType: 'lite',
instanceType: overrides?.instanceType ?? 'lite',
maxInstances: 20,
migrations: [{ tag: 'sandbox-v1', newSqliteClasses: ['Sandbox'] }],
},
Expand Down Expand Up @@ -890,6 +891,16 @@ describe('per-deploy sandbox integration', () => {
expect(raw).toBeNull();
});

it('accepts basic sandbox instanceType at deploy validation', async () => {
const user = await createTestUser(env.db, 'sb-basic-user', 'github', undefined, 'pro');
const project = await createTestProject(env.db, user.id, 'sb-basic-size');
mockCfApi();

const res = await deploy(project.id, user.jwt, buildSandboxManifest({ instanceType: 'basic' }));
expect(res.status).toBe(200);
expect(getDoneEvent(await readAllEvents(res))).toBeDefined();
});

it('rejects manifest.sandbox for static/spa deployments at validation time', async () => {
const user = await createTestUser(env.db, 'sb-p6-static-user', 'github', undefined, 'pro');
const project = await createTestProject(env.db, user.id, 'sb-p6-static');
Expand Down