Repository navigation
feat(docker): introduce docker swarm resources - #972
Merged
Merged
Conversation
Docker.Service is now a Platform (like AWS.ECS.Service): pass `main` and an
Effect impl to bundle the program into a content-addressed image built
against the service's Docker context and deployed as a swarm service. The
impl returns `{ fetch }` (served by a Bun HTTP server on `port`) and can
register background loops via ServerHost.run.
- move createContainerRuntimeContext to Server/Process.ts (shared by ECS
Task/Service and Docker.Service; re-exported from AWS/ECS/Task.ts)
- new internal Docker/ServiceImage.ts: rolldown bundle + bun bootstrap +
generated Dockerfile, built with the Docker CLI against the target
context; content hash drives diff and skips redundant builds
- diff compares the bundled code hash against output.code.hash; delete
removes the built image best-effort
- cap swarm service physical names at 63 chars (swarm limit)
- full JSDoc (@section/@example) for Docker.Service and Docker.Context;
relative imports in the PR alchemy-run#972 files
- e2e fixture + Service.platform.test.ts proving fetch serving, ServerHost
background loops, noop redeploys, and clean destroy (service + image)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # packages/alchemy/src/Docker/Service.ts
Member
|
I updated your PR to include Effectful support for Docker.Service |
…swarm Replace the provider-method diff unit tests with real engine lifecycle deploys (replicas replace, context replace), and make the swarm suites self-sufficient locally: ensureDockerSwarm idempotently runs `docker swarm init --advertise-addr 127.0.0.1` when the engine is swarm-inactive, so the tests run anywhere Docker runs. Every test ends with stack.destroy() and the create test proves the service is gone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The guide assumed an existing swarm without saying so. Add a "Setting up the swarm" section (docker swarm init locally, over an SSH context, and multi-node join + node labels) and state on the Service resource that the target engine must be a swarm manager, pointing to Docker.Container for non-swarm single containers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Docker.Swarm is an idempotent `docker swarm init` on a target engine:
observe swarm state, init when inactive (advertiseAddr/listenAddr/
defaultAddrPool/subnetSize apply at init only), adopt-gate engines that
are already swarm managers, and `docker swarm leave --force` on destroy.
Service and Network `context` now accept a Docker.Swarm (Docker.EngineRef)
so workloads deploy after the swarm exists and inherit its context:
```ts
const swarm = yield* Docker.Swarm("swarm");
const web = yield* Docker.Service("web", { context: swarm, image: "nginx:alpine" });
```
Tests run against a disposable docker:dind engine so the host's swarm
state is never touched: greenfield init + service deploy + destroy
(swarm dissolved, context removed), and adopt-vs-refuse on a
pre-initialized engine.
Rewrite the swarm guide step-by-step (one concept per snippet): create/
adopt the swarm, deploy services, overlay networks, effectful services,
remote SSH deploys, multi-node growth, dev-vs-prod stack.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`main` only changes where the image comes from — the deploy still targets a swarm manager, so every example now passes `context: swarm`, including the class form via Effect-valued props yielding a module-level Swarm. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t carries no credentials - swarm.mdx "Use an existing swarm" now covers both paths: reference (pass a context to services; swarm lifecycle stays external) and adopt (swarm becomes stack-owned; destroy dissolves membership) - same two examples on the Swarm resource JSDoc - document on ContextProps.docker that the endpoint spec is connection metadata only — SSH auth is key/agent-based and TLS material is referenced by file path, so the string never needs Redacted Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sam-goodwin
added a commit
that referenced
this pull request
Jul 29, 2026
…swarm #972) into url redesign Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sam-goodwin
added a commit
that referenced
this pull request
Jul 29, 2026
The website build's diff-indent check requires +/- markers as an extra column before the code's full indentation, and at least one flush context line so expressive-code doesn't strip a marker column from every line. Fixes the telemetry tutorial's one-space-short markers and anchors the swarm doc's fragment with its enclosing call. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sam-goodwin
added a commit
that referenced
this pull request
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Docker Swarm support, from provisioning the swarm to running effectful services on it:
Docker.Swarm— idempotentdocker swarm initon a target engine; adoptable when the engine is already a swarm managerDocker.Context— a named Docker CLI context (local socket, SSH host, TCP endpoint); existing Docker resources accept it via theircontextpropDocker.Service— a replicated swarm service, promoted to an effectful platform likeAWS.ECS.ServiceProvision the swarm, deploy into it
Serviceand overlayNetworktake the swarm (or aDocker.Context/ context name) ascontext. An engine that is already in swarm mode is foreign untiladopt(true); destroying the swarm resource runsdocker swarm leave --force. Multi-node membership (join tokens) remains host-level CLI setup for now.Effectful services
Pass
mainand an Effect impl instead of a pre-built image. Alchemy bundles the program, builds a content-addressed image against the swarm's engine, and deploys it as a swarm service:{ fetch }handler is served by a Bun HTTP server onport;portspublishes it through the swarm routing mesh<name>:<hash>): unchanged code redeploys as a noop, changed code replaces the service with the new imageDocker.Image+registryand pass the pushed ref asimageTests
All deploy-through against real engines: the
Docker.Swarmlifecycle (greenfield init, adopt-vs-refuse, destroy) runs on a disposabledocker:dindengine so the host swarm is never touched; theDocker.Servicesuites self-provision a local single-node swarm and cover create/replace/adopt plus an end-to-end effectful service (fetchserved,ServerHost.runloop observed over HTTP, noop redeploy, clean destroy).See the step-by-step Docker Swarm guide covering local dev through remote SSH deployment.