alepha@docs:~/docs/reference/primitives$
cat $container.md | pretty1 min read
#$container
#Import
typescript
1import { $container } from "alepha/containers";
#Overview
$container — typed RPC client to a containerized Alepha app.
Returns a typed Proxy whose method calls map 1:1 to the target
controller's $action endpoints. The wire format mirrors what a
normal Alepha server exposes (POST /api/<method> with a JSON body),
so the container is literally a tiny Alepha worker.
Transport is owned by the active {@link ContainerProvider}:
target=cloudflare→CloudflareContainerProviderroutes through the Containers binding (env.<NAME>.getContainer(...).fetch()).- Node (with
urlset) →NodeContainerProvideruses plainfetch()against the configured URL.
Build-time, BuildCloudflareTask.enhanceContainers walks
alepha.primitives($container) to emit the matching wrangler.jsonc
entries and Durable Object class declarations into
main.cloudflare.js.
#Examples
ts
1import { $container } from "alepha/containers"; 2import type { RocketController } from "@alepha/rocket"; 3 4class DeployService { 5 rocket = $container<RocketController>({ 6 image: "alepha/rocket:latest", 7 port: 3000, 8 sleepAfter: "15m", 9 });10 11 async deploy() {12 return this.rocket.createJob({ body: { op: "up" } });13 }14}