What the agent does
The agent reads how the Worker is built and configured before writing a Dockerfile. In a project like temporalio/money-transfer-project-template-ts, .nvmrc names Node 18 and tsconfig.json extends @tsconfig/node18, compiling src/ into lib/ with declarations and source maps. package.json has build as tsc --build, worker as ts-node src/worker.ts, client as ts-node src/client.ts, test running Mocha through ts-node over src/mocha/*.test.ts, and lint as eslint src; the runtime dependencies are the @temporalio/* packages at ~1.14.1 plus nanoid, and .gitignore lists lib, node_modules and coverage. src/worker.ts calls loadClientConnectConfig() from @temporalio/envconfig, falls back to localhost:7233 and the default namespace, opens a NativeConnection and creates a Worker with workflowsPath: require.resolve('./workflows'), the activities module and the money-transfer task queue from src/shared.ts. The banking client in src/banking-client.ts is a mock that makes no network calls, so the Worker needs nothing but a Temporal server.
From that it writes a Dockerfile in three stages. The first installs with npm ci from package.json and package-lock.json, the second runs npm run build so lib/worker.js, lib/workflows.js, lib/activities.js and lib/shared.js exist, and the final stage starts from the same Node major on a Debian-based image, copies package*.json, installs with npm ci --omit=dev, copies lib/ and runs node lib/worker.js as a non-root user. The base image matters here: @temporalio/core-bridge ships a native library, so the agent checks the package's prebuilt binaries for a musl variant before deciding whether an Alpine image is even an option, and says what it found in the pull request. require.resolve('./workflows') resolves to lib/workflows.js at runtime and the Worker bundles the Workflow code when it starts, so lib/ must be complete in the final image; .dockerignore excludes node_modules, lib, .git and coverage so the build context is the sources.
Configuration stays with @temporalio/envconfig. The agent sets nothing in the image and documents the TEMPORAL_ADDRESS and TEMPORAL_NAMESPACE environment variables the config loader reads, so the same image points at a local dev server, a self-hosted cluster or Temporal Cloud. A compose.yaml runs the Worker beside a Temporal dev server, as Temporal's own docker-compose repository does with the auto-setup image and a database, with the Worker's address set to that service's name and depends_on so it starts after the server. The README's npm run worker step gains a docker compose up alternative, and npm run client still runs from the host against the published port.
The sandbox has no Docker, so the agent installs it first (sudo apt-get install -y docker.io, then starts dockerd), builds the image, brings the Compose stack up with docker-compose, and runs npm run client from the sandbox against the published port. The Workflow's return value, Transfer complete with two transaction ids, is the check that the containerised Worker picked the task up; it also runs npm test, whose Mocha suite starts a local test server through @temporalio/testing, to show the code itself is unchanged.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Dockerize this Temporal TypeScript Worker. Read package.json, package-lock.json, .nvmrc, tsconfig.json, src/worker.ts, src/client.ts, src/shared.ts and the README first. Write a multi-stage Dockerfile that installs with npm ci, builds with tsc into lib, and runs node lib/worker.js as a non-root user on a Debian-based Node image matching .nvmrc; check whether @temporalio/core-bridge ships a musl build before considering Alpine and say what you found. Add a .dockerignore. Configure the connection only through the environment variables @temporalio/envconfig reads and document them. Add a compose.yaml that runs the Worker beside a Temporal dev server and update the README. Install Docker in the sandbox, build the image, start the stack, run npm run client against it and confirm the Workflow completes, run npm test, and open a pull request that pastes the client output and the image size.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request on its own branch with Dockerfile, .dockerignore, compose.yaml and a README section on running the Worker in a container. No TypeScript changes, no new dependencies and no change to package.json scripts, unless the prompt asks for a docker:build script.
The description lists each stage of the image and why it is there, the environment variables the Worker reads, the note on the native core library and the base image choice, the npm run client output showing the Workflow completed through the containerised Worker, and the Mocha summary. The commands are in the transcript at GET /o/{org}/sessions/{id}/messages with their output.
Before merging, a reviewer builds the image on a laptop or in CI, points it at a real namespace with the documented variables, and decides whether the Compose file should also run the Temporal Web UI, which the pull request names as an option but does not add.
Run it on every new Worker repository
Start one run per Worker from your own server: POST /o/{org}/sessions with this prompt and that repository in resources, one call each. GET /o/{org}/github lists every repository the Rush GitHub App installation can reach, so a script can find the ones that depend on @temporalio/worker and have no Dockerfile, and start a run for each. Each run has its own sandbox and its own branch.
Give the key a webhook_url and each run POSTs run.completed with its session_url when the turn finishes, so the pull request links collect on your side without polling. A key may have at most max_concurrent runs in progress at once, 4 by default, and starting one more answers 202 with status: "queued", so a script over many repositories can start every run up front and let each wait for a free slot.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A Worker image is easy to get almost right: the build stage compiles, the container starts, and then the Worker cannot bundle its Workflows because lib/ is incomplete, or the native core library will not load on the base image chosen. Each of those shows up only when the container runs against a server. In a Rush sandbox the agent installs Docker, starts a real Temporal dev server and runs a Workflow through the image before the branch exists, so the version you review is the one that worked.
The pull request carries that proof: the build log, the Compose startup and the client output sit beside the commands that produced them in the transcript. Several Workers can be containerised at once, each in its own sandbox, with one pull request each.
Frequently asked questions
Can the image use Alpine?
The agent checks rather than assumes. @temporalio/core-bridge ships prebuilt native binaries, and the pull request states whether a musl build was among them for the version the lockfile pins. The Dockerfile uses a Debian-based Node image by default, which matches what ts-node runs on in development.
Does the Worker need the TypeScript sources at runtime?
No. The final stage copies only lib/, the compiled output of tsc --build, plus production node_modules. The Worker's workflowsPath resolves to lib/workflows.js, and the Worker bundles that file and its imports when it starts, so nothing from src/ is needed.
How does the container find my Temporal server?
Through the variables @temporalio/envconfig already reads in src/worker.ts, such as TEMPORAL_ADDRESS and TEMPORAL_NAMESPACE. Nothing is baked into the image, so the same build runs against the Compose dev server, a self-hosted cluster or Temporal Cloud.
Will the existing tests still run?
Yes. The Mocha suite in src/mocha/ uses @temporalio/testing to start its own local test server and is untouched. The agent runs npm test in the sandbox and pastes the summary, alongside the client run against the containerised Worker.
More Temporal jobs
The same job on other stacks
- Dockerize a Vite React App (Vite + React)
- Dockerize a Vue App (Vue)
- Dockerize an Actix Web App (Actix Web)