@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
md 51 lines 1.8 KB
Rendered Raw
1 # @alchemy.run/docker
2
3 Docker for [Alchemy](https://alchemy.run). Declare images, containers, networks, and volumes as typed resources, driven through your active Docker context. Other Alchemy providers use it to build and push the images they deploy.
4
5 ```sh
6 npm install alchemy @alchemy.run/docker effect
7 ```
8
9 A local Postgres with a generated password, a network, and a data volume:
10
11 ```typescript
12 // alchemy.run.ts
13 import * as Alchemy from "alchemy";
14 import * as Docker from "@alchemy.run/docker";
15 import * as Effect from "effect/Effect";
16 import * as Layer from "effect/Layer";
17
18 export default Alchemy.Stack(
19 "MyApp",
20 {
21 providers: Layer.merge(Docker.providers(), Alchemy.RandomProvider()),
22 state: Alchemy.localState(),
23 },
24 Effect.gen(function* () {
25 const password = yield* Alchemy.makeRandom("PostgresPassword", { bytes: 16 });
26 const image = yield* Docker.RemoteImage("Postgres", { name: "postgres", tag: "18-alpine" });
27 const network = yield* Docker.Network("Network");
28 const data = yield* Docker.Volume("Data");
29
30 const postgres = yield* Docker.Container("Db", {
31 image,
32 environment: { POSTGRES_PASSWORD: password },
33 ports: [{ external: 15432, internal: 5432 }],
34 volumes: [{ hostPath: data.name, containerPath: "/var/lib/postgresql/data" }],
35 networks: [{ name: network.name, aliases: ["postgres"] }],
36 start: true,
37 });
38
39 return { container: postgres.name };
40 }),
41 );
42 ```
43
44 `alchemy deploy` pulls the image and starts the container. Change a prop and the next deploy replaces only what changed; `alchemy destroy` removes all of it.
45
46 ## Learn more
47
48 - [Docker on alchemy.run](https://alchemy.run/docker)
49 - [Setup](https://alchemy.run/docker/setup)
50 - [Build and push images](https://alchemy.run/docker/build-and-push)
51 - [API reference](https://alchemy.run/providers)