Docs

API Reference

Constructor

new alien.Container(id: string)
ParameterTypeRequiredDescription
idstringYesContainer resource ID. Use lowercase DNS-compatible names such as api or vector-reader.

code

Sets what the container runs.

.code({ type: "image", image: "ghcr.io/acme/api:v1" })
.code({ type: "source", src: "./api", toolchain: { type: "docker" } })
FieldTypeRequiredDescription
type"image" | "source"YesUse an existing image or build from source.
imagestringFor imageContainer image reference.
srcstringFor sourceSource directory.
toolchainToolchainConfigFor sourceBuild toolchain.

If you use image, Alien deploys that image directly. If you use source, Alien runs the selected toolchain during build/release and turns the result into a container image. In both cases the configured image command starts your app directly; there is no Worker runtime wrapper in front of a Container.

Supported source toolchains are the same toolchains used by Workers:

ToolchainUse For
typescriptTypeScript or JavaScript projects compiled with Bun.
rustRust projects compiled with Cargo.
dockerProjects with a Dockerfile.

cpu

Sets CPU requirements.

.cpu(1)
.cpu({ min: "0.5", desired: "2" })
ParameterTypeRequiredDescription
valuenumber | { min: string; desired: string }YesCPU in vCPUs. A number sets both min and desired.

memory

Sets memory requirements.

.memory("1Gi")
ParameterTypeRequiredDescription
sizestringYesMemory request, for example "512Mi", "1Gi", or "16Gi".

ports

Adds internal ports.

.port(8080)
.ports([8080, 9090])
MethodDescription
.port(port)Adds one internal port.
.ports(ports)Adds several internal ports.

Every container must define at least one port.

publicEndpoint

Publicly exposes a named endpoint through provider load-balancing infrastructure.

.port(8080)
.publicEndpoint("web", 8080, "http")

.publicEndpoint("admin", 9090, "tcp")

.publicEndpoint("tenants", 8080, {
  protocol: "http",
  hostLabel: "tenants",
  wildcardSubdomains: true,
})
MethodDescription
.publicEndpoint(name, port, options)Exposes a specific port as a named endpoint.

Options can be a protocol string ("http" or "tcp") or an object:

FieldTypeDefaultDescription
protocol"http" | "tcp"Endpoint protocol. HTTP endpoints terminate TLS at the load balancer; TCP endpoints pass traffic through.
hostLabelstringendpoint nameHost label on the deployment domain. "@" serves the endpoint at the domain apex.
wildcardSubdomainsbooleanfalseAlso routes *.<hostLabel>.<deployment-domain> to the endpoint. Cannot be combined with the apex host label.

Additional ports remain internal unless they have their own endpoint. See External URLs for how hostnames, DNS, and TLS work.

replicas and autoscaling

.replicas(3)

.minReplicas(2)
.maxReplicas(20)

.autoScale({
  min: 2,
  desired: 4,
  max: 20,
  targetCpuPercent: 70,
  targetMemoryPercent: 80,
  targetHttpInFlightPerReplica: 100,
})
MethodDescription
.replicas(count)Fixed replica count.
.minReplicas(count)Sets autoscaling minimum and desired replicas.
.maxReplicas(count)Sets autoscaling maximum replicas.
.autoScale(config)Sets the full autoscaling object.

Use either fixed replicas or autoscaling.

stateful and storage

.stateful(true)
.persistentStorage("500Gi")
.persistentStorage("500Gi", { mountPath: "/var/lib/postgresql/data" })
.ephemeralStorage("100Gi")
MethodDescription
.stateful(enabled)Enables stable replica identity. Replicas get stable ordinals (api-0, api-1, …).
.persistentStorage(size, options?)Adds persistent storage and marks the container stateful. options.mountPath sets the mount path (default /data).
.ephemeralStorage(size)Requests scratch storage that may be lost when a replica restarts or moves.

Each ordinal keeps its volume: the volume survives replica restarts and replacement, and the replica is placed where its volume lives.

gpu

.gpu({ type: "nvidia-t4", count: 1 })
FieldTypeRequiredDescription
typestringYesGPU type identifier.
countnumberYesNumber of GPUs.

GPU placement depends on the machine pools available for the deployment.

healthCheck

.healthCheck({
  path: "/health",
  port: 8080,
  method: "GET",
  timeoutSeconds: 1,
  failureThreshold: 3,
})
FieldTypeDefaultDescription
pathstring"/health"HTTP path to check.
portnumberContainer portPort to check.
methodstring"GET"HTTP method.
timeoutSecondsnumber1Probe timeout.
failureThresholdnumber3Consecutive failures before unhealthy.
.environment({ LOG_LEVEL: "info" })
.link(storage)
.permissions("execution")
MethodRequiredDescription
.environment(vars)NoMerges environment variables into the container config.
.link(resource)NoInjects binding access to another resource.
.permissions(profile)YesPermission profile name.

placement

.cluster("compute")
.pool("gpu")
MethodDescription
.cluster(id)Advanced: run on a specific container cluster. If omitted, Alien can assign or create the default cluster.
.pool(name)Advanced: run on a specific machine pool within the cluster.

command

.command(["./server", "--port", "8080"])

Overrides the image default command. The container runs your entrypoint directly — there is no runtime wrapper. Bindings run in-process via @alienplatform/bindings.

stopGracePeriod

.stopGracePeriod(300)

Grace period in seconds used when stopping replicas during updates, drains, and deletes. Valid values are 1 through 86400.

commandsEnabled

Enables or disables the Commands protocol.

.commandsEnabled(true)
ParameterTypeDefaultDescription
enabledbooleanfalseWhen enabled, Alien injects the command-receiver environment so the container's own pull receiver (createCommandReceiver) can lease and dispatch commands. See Remote Commands.

Outputs

Container outputs are available in stack state after provisioning.

FieldTypeDescription
namestringRuntime container name.
status"pending" | "running" | "stopped" | "failing"Current status.
currentReplicasnumberReplicas currently running.
desiredReplicasnumberTarget replica count.
internalDnsstringInternal service DNS name.
publicEndpointsRecord<string, PublicEndpointOutput>Public endpoints keyed by endpoint name.
replicasReplicaStatus[]Per-replica status details when reported by the platform. Stateful replicas include their ordinal.

On this page