@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
ts 49 lines 1.76 KB
Raw
1 import * as Docker from "@alchemy.run/docker";
2 import * as Effect from "effect/Effect";
3 import { HttpServerRequest } from "effect/http/HttpServerRequest";
4 import * as HttpServerResponse from "effect/http/HttpServerResponse";
5 import { isolatedProject } from "../../IsolatedProject.ts";
6
7 /**
8 * The isolated consumer project this service is bundled from (see
9 * `test/IsolatedProject.ts`): `main` lives outside the repository, so the
10 * bundle `cwd` resolves none of alchemy's dependencies and the bun
11 * bootstrap's own imports must be anchored by the bundler.
12 */
13 export const project = isolatedProject("docker-service", import.meta.filename, [
14 "@alchemy.run/docker",
15 ]);
16
17 /**
18 * Fixed host port published through the swarm ingress. Deterministic and
19 * distinct from the other Docker suites on the shared local daemon.
20 */
21 export const SERVICE_EXTERNAL_PORT = 43119;
22
23 /**
24 * Minimal effectful `Docker.Service` served from an isolated project.
25 * `/health` answering 200 proves the generated bootstrap booted — with its
26 * imports left external bun dies at module load and the swarm task
27 * restart-loops without ever listening.
28 */
29 export default class IsolatedProjectService extends Docker.Service<IsolatedProjectService>()(
30 "DockerIsolatedProjectService",
31 {
32 main: project.main,
33 port: 3000,
34 ports: [{ external: SERVICE_EXTERNAL_PORT, internal: 3000 }],
35 replicas: 1,
36 },
37 Effect.gen(function* () {
38 return {
39 fetch: Effect.gen(function* () {
40 const request = yield* HttpServerRequest;
41 const url = new URL(request.url, "http://service");
42 if (url.pathname === "/health") {
43 return yield* HttpServerResponse.json({ ok: true });
44 }
45 return HttpServerResponse.text("hello from isolated project");
46 }),
47 };
48 }),
49 ) {}