@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 31 lines 1.06 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Effect from "effect/Effect";
3 import * as HttpServerResponse from "effect/http/HttpServerResponse";
4
5 declare const BUNDLE_MARKER: string;
6
7 export class LinkedContainer extends Cloudflare.Container<
8 LinkedContainer,
9 { marker: () => Effect.Effect<string> }
10 >()("LinkedContainer") {}
11
12 /**
13 * A generated-Dockerfile container whose bundle bytes change with `marker`,
14 * so each entrypoint publishes a new image over the same base layers.
15 */
16 export const linkedContainer = (main: string, marker: string) =>
17 LinkedContainer.make(
18 {
19 main,
20 image: "oven/bun:latest",
21 build: { input: { transform: { define: { BUNDLE_MARKER: JSON.stringify(marker) } } } },
22 },
23 Effect.sync(() => {
24 // Only the bundle defines the marker; deploy-time runs see the argument.
25 const bundled = typeof BUNDLE_MARKER === "string" ? BUNDLE_MARKER : marker;
26 return {
27 marker: () => Effect.succeed(bundled),
28 fetch: Effect.succeed(HttpServerResponse.text(bundled)),
29 };
30 }),
31 );