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.
| Method | Type | Default | Notes |
|---|---|---|---|
.code(code) | ContainerCode | required | Image or source build. Same values as Worker toolchains. |
.cpu(value) | number | { min, desired } | { min, max, default } | required | vCPUs. 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 } | required | Ki/Mi/Gi/Ti suffix, for example "512Mi". Ranges work like cpu. |
.permissions(profile) | string | required | Permission profile name. |
.port(n) / .ports(ns) | number / number[] | none | Internal 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 network | Allows 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) | number | none | Fixed count. Clears autoscaling. |
.minReplicas(n) | number | none | Sets min and desired to n, and max to 10 × n. |
.maxReplicas(n) | number | none | Sets max. Min and desired default to 1. |
.autoScale(cfg) | { min, desired, max, targetCpuPercent?, targetMemoryPercent?, targetHttpInFlightPerReplica?, maxHttpP95LatencyMs? } | none | CPU target defaults to 70%, memory to 80%. |
.stateful(on) | boolean | false | Stable ordinals (api-0, api-1). |
.persistentStorage(size, opts?) | string, PersistentStorageOptions | none | Sets stateful(true). |
.ephemeralStorage(size) | string | platform default | Scratch space. Not persisted; keep nothing there you need later. |
.gpu({ type, count }) | { type: string, count: number } | none | type such as "nvidia-a100" or "nvidia-t4". count 1 to 8. |
.healthCheck(cfg) | HealthCheck | none | Used during rollout and refresh. |
.readinessProbe({ method, path }) | none | Shorthand for .healthCheck() with timeout 1 and failure threshold 3. | |
.command(args) | string[] | image default | Replaces the image's entrypoint and command. The first item runs, with the rest as its arguments. |
.stopGracePeriod(sec) | number | backend default | 1 to 86,400 seconds. |
.environment(vars) | Record<string, string> | {} | Merges into the existing map. |
.link(resource) | Resource | none | Repeatable. |
.commandsEnabled(on) | boolean | false | Injects ALIEN_COMMANDS_*. Your app runs createCommandReceiver() itself. |
.cluster(id) | string | default cluster | ComputeCluster id. |
.pool(name) | string | automatic | Capacity group within the cluster. |
.security(cfg) | { profile: "restricted" | "unrestricted", runAsUser, runAsGroup, readOnlyRootFilesystem, writablePaths } | none | Portable security profile and process identity. Without it the container runs as its image was built. See Pod security. Refused on Local. |
.kubernetesSecretMount({ secretName, mountPath }) | none | Mounts an existing Secret from the deployment namespace, read-only. Kubernetes only. | |
.kubernetesLivenessProbe({ path, port }) / .kubernetesReadinessProbe({ path, port }) | none | Kubernetes HTTP probes. Kubernetes only. | |
.enabled(input) | boolean input | always | Creates 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 })| Option | Type | Notes |
|---|---|---|
protocol | "http" | "tcp" | HTTP terminates TLS at the load balancer. TCP passes traffic through. TCP works on AWS, Google Cloud, Azure, and Local. |
hostLabel | string | DNS label for the generated hostname. Defaults to the endpoint name. "@" uses the apex, and only one endpoint per container can. |
wildcardSubdomains | boolean | Also 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
| Option | Type | Default | Notes |
|---|---|---|---|
mountPath | string | /data | |
encryptionKey | Key resource | provider key | Customer-managed Key in the same stack. Changing it replaces the resource. |
backups | false | { intervalHours?, retentionDays? } | on | intervalHours: 1, 2, 4, 6, 8, 12, or 24 (default 24). retentionDays: 1 to 365 (default 7). |
Health checks
| Field | Default | Notes |
|---|---|---|
path | /health | |
method | GET | |
port | container port | |
timeoutSeconds | 1 | 1 to 5. |
failureThreshold | 3 |
SDK
TypeScript
import { container } from "@alienplatform/sdk"
const search = container("search")| Method | Returns | Notes |
|---|---|---|
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")| Method | Returns |
|---|---|
await internal_url() | str |
await internal_urls() | dict[int, str] |
await public_url() | str | None |
Outputs
| Field | Notes |
|---|---|
name | Runtime container name. |
status | pending, running, stopped, or failing. |
currentReplicas, desiredReplicas | Replica counts. |
internalDns | Internal service DNS name. |
publicEndpoints | Public endpoints by name. |
replicas | Per-replica status, with ordinal for stateful replicas. |
volumeBackups.state | active, 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
| Command | Does |
|---|---|
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.