Toolchains
.code() tells Alien where the code is and how to build it. Point it at source with a toolchain, or at a prebuilt image. Container, Daemon, and Sandbox accept the same values.
TypeScript
new alien.Worker("api")
.code({ type: "source", src: "./api", toolchain: { type: "typescript" } })Alien installs dependencies with the package manager it detects from the lockfile (bun, pnpm, or npm), generates a small bootstrap that connects your module to the Worker runtime, and builds it with Bun.
The entry point is the first file that exists among main, module, and source in package.json, then src/index.ts, src/index.js, index.ts, index.js. Export your HTTP app (Hono, Express, or anything with a fetch handler) as the default export:
import { Hono } from "hono"
const app = new Hono()
app.get("/health", c => c.json({ ok: true }))
export default app| Option | Default | Notes |
|---|---|---|
binaryName | name in package.json | Name of the compiled binary. |
Rust
new alien.Worker("agent")
.code({ type: "source", src: "./agent", toolchain: { type: "rust", binaryName: "my-agent" } })Alien builds the named Cargo binary as a static Linux musl executable.
- Building for the host's own Linux architecture uses the native musl compiler. Install
musl-tools(x86_64-linux-musl-gccoraarch64-linux-musl-gcc). Without it, Alien falls back tocargo zigbuildif Zig is installed. - Building for another Linux architecture uses
cargo zigbuildand needs Zig. - Windows targets built off Windows use
cargo xwin. macOS targets need a macOS host and the Apple SDK.
| Option | Default | Notes |
|---|---|---|
binaryName | required | The Cargo binary target. |
Python
new alien.Worker("jobs")
.code({
type: "source",
src: "./jobs",
toolchain: { type: "python", command: ["python", "-m", "jobs"] },
})The project needs pyproject.toml and uv.lock. Alien builds on python:<version>-slim-bookworm, runs uv sync --frozen --no-dev, and starts command. Python Workers handle queue messages through alienplatform[worker]; see the API reference.
| Option | Default | Notes |
|---|---|---|
command | required | Process argv that starts the app. |
pythonVersion | "3.12" | 3.10, 3.11, 3.12, or 3.13. |
package | none | Workspace package to install. Omit for a single-package project. |
Docker
new alien.Worker("service")
.code({
type: "source",
src: "./service",
toolchain: {
type: "docker",
dockerfile: "Dockerfile.prod",
buildArgs: { NODE_ENV: "production" },
target: "runtime",
},
})Alien builds with docker buildx for the target architecture. Use it when the other toolchains don't fit your build. If the active builder can't build the target architecture, the build fails and asks you to build on a native runner or configure emulation.
| Option | Default | Notes |
|---|---|---|
dockerfile | "Dockerfile" | Path relative to src. |
buildArgs | {} | Passed to the build. |
target | none | Multi-stage build target. |
Prebuilt image
new alien.Worker("api")
.code({ type: "image", image: "ghcr.io/acme/api:1.4.0" })Alien deploys the image as is. Use this when your own CI builds images.
A Worker's prebuilt image isn't copied into the release, so the cloud must be able to pull it without credentials. For an image in a private registry, use the Docker toolchain with a Dockerfile that starts FROM it, so the image is copied with the release.
Architecture
On AWS, Workers run on ARM64. Source builds target the stack's build architecture, and on Kubernetes Pods are scheduled on nodes of that architecture.