Docs

Container API reference

Every option of the Container builder in alien.ts, the SDK clients that resolve a container's URLs, its outputs, and the CLI commands for its volumes.

Builder

new alien.Container(id) from @alienplatform/core. The id uses lowercase letters, digits, and hyphens.

MethodTypeDefaultNotes
.code(code)ContainerCoderequiredImage or source build. Same values as Worker toolchains.
.cpu(value)number | { min, desired } | { min, max, default }requiredvCPUs. A number sets min and desired. A { min, max, default } range lets the deployer (the person who sets up the deployment) choose at deploy time.
.memory(value)string | { min, desired } | { min, max, default }requiredKi/Mi/Gi/Ti suffix, for example "512Mi". Ranges work like cpu.
.permissions(profile)stringrequiredPermission profile name.
.port(n) / .ports(ns)number / number[]noneInternal ports, reachable inside the cluster and by resources that link to this container.
.publicEndpoint(name, port, opts?)"http" | "tcp" | PublicEndpointOptions"http"Adds port to the ports if it's missing. See Public endpoints.
.egress("internet")"internet"full networkAllows only public addresses, the container's own replicas on declared TCP ports, and the credential proxy. AWS, Google Cloud, and Azure only. Requires security.profile: "restricted".
.replicas(n)numbernoneFixed count. Clears autoscaling.
.minReplicas(n)numbernoneSets min and desired to n, and max to 10 × n.
.maxReplicas(n)numbernoneSets max. Min and desired default to 1.
.autoScale(cfg){ min, desired, max, targetCpuPercent?, targetMemoryPercent?, targetHttpInFlightPerReplica?, maxHttpP95LatencyMs? }noneCPU target defaults to 70%, memory to 80%.
.stateful(on)booleanfalseStable ordinals (api-0, api-1).
.persistentStorage(size, opts?)string, PersistentStorageOptionsnoneSets stateful(true).
.ephemeralStorage(size)stringplatform defaultScratch space. Not persisted; keep nothing there you need later.
.gpu({ type, count }){ type: string, count: number }nonetype such as "nvidia-a100" or "nvidia-t4". count 1 to 8.
.healthCheck(cfg)HealthChecknoneUsed during rollout and refresh.
.readinessProbe({ method, path })noneShorthand for .healthCheck() with timeout 1 and failure threshold 3.
.command(args)string[]image defaultReplaces the image's entrypoint and command. The first item runs, with the rest as its arguments.
.stopGracePeriod(sec)numberbackend default1 to 86,400 seconds.
.environment(vars)Record<string, string>{}Merges into the existing map.
.link(resource)ResourcenoneRepeatable.
.commandsEnabled(on)booleanfalseInjects ALIEN_COMMANDS_*. Your app runs createCommandReceiver() itself.
.cluster(id)stringdefault clusterComputeCluster id.
.pool(name)stringautomaticCapacity group within the cluster.
.security(cfg){ profile: "restricted" | "unrestricted", runAsUser, runAsGroup, readOnlyRootFilesystem, writablePaths }nonePortable security profile and process identity. Without it the container runs as its image was built. See Pod security. Refused on Local.
.kubernetesSecretMount({ secretName, mountPath })noneMounts an existing Secret from the deployment namespace, read-only. Kubernetes only.
.kubernetesLivenessProbe({ path, port }) / .kubernetesReadinessProbe({ path, port })noneKubernetes HTTP probes. Kubernetes only.
.enabled(input)boolean inputalwaysCreates the resource only when the input is true.

Changing the id, cluster, stateful mode, ports, public endpoints, pool, or persistentStorage.encryptionKey replaces the resource.

Public endpoints

.publicEndpoint("web", 8080)                                   // HTTP
.publicEndpoint("db", 5432, "tcp")
.publicEndpoint("app", 8080, { protocol: "http", hostLabel: "@", wildcardSubdomains: false })
OptionTypeNotes
protocol"http" | "tcp"HTTP terminates TLS at the load balancer. TCP passes traffic through. TCP works on AWS, Google Cloud, Azure, and Local.
hostLabelstringDNS label for the generated hostname. Defaults to the endpoint name. "@" uses the apex, and only one endpoint per container can.
wildcardSubdomainsbooleanAlso routes wildcard subdomains to this endpoint. Not allowed on the apex endpoint. Default false.

Endpoint names are lowercase DNS labels, up to 63 characters. All public endpoints on one container use the same backend port and the same protocol.

Persistent storage

OptionTypeDefaultNotes
mountPathstring/data
encryptionKeyKey resourceprovider keyCustomer-managed Key in the same stack. Changing it replaces the resource.
backupsfalse | { intervalHours?, retentionDays? }onintervalHours: 1, 2, 4, 6, 8, 12, or 24 (default 24). retentionDays: 1 to 365 (default 7).

Health checks

FieldDefaultNotes
path/health
methodGET
portcontainer port
timeoutSeconds11 to 5.
failureThreshold3

SDK

TypeScript

import { container } from "@alienplatform/sdk"

const search = container("search")
MethodReturnsNotes
getInternalUrl()Promise<string>URL of the first port.
getInternalUrls()Promise<Record<number, string>>URL per port.
getPublicUrl()Promise<string | null>URL of the first declared public endpoint. null when the container has none.

Python

from alienplatform import container

search = container("search")
MethodReturns
await internal_url()str
await internal_urls()dict[int, str]
await public_url()str | None

Outputs

FieldNotes
nameRuntime container name.
statuspending, running, stopped, or failing.
currentReplicas, desiredReplicasReplica counts.
internalDnsInternal service DNS name.
publicEndpointsPublic endpoints by name.
replicasPer-replica status, with ordinal for stateful replicas.
volumeBackups.stateactive, disabled, or setupRequired. With setupRequired, volumeBackups.message says what is missing.
volumes[]ordinal, volumeId, zone, lastSnapshotId, lastSnapshotAt, and lastRestore for each replica's volume.

CLI

CommandDoes
alien deployments volumes <deployment>Lists container volumes, their latest snapshots, and restores.
alien deployments restore-volume <deployment> --resource <id> --ordinal <n> --snapshot <snapshot-id>Restores one replica's volume from a snapshot.
alien deployments cancel-volume-restore <deployment> <restore-id>Cancels a volume restore.

<deployment> is a deployment id or <deployment-group>/<deployment-name>. Each command accepts --json.

On this page