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

main
ts 49 lines 1.89 KB
Raw
1 import { Task } from "@alchemy.run/aws/ECS/Task";
2 import * as Dockerfile from "@alchemy.run/docker/Dockerfile";
3 import * as Effect from "effect/Effect";
4 import * as FileSystem from "effect/FileSystem";
5
6 /**
7 * A one-shot `AWS.ECS.Task` whose ENVIRONMENT is inline Dockerfile content
8 * (`Dockerfile.inline`) composed with a bundled `main` program.
9 *
10 * The inline content carries its own `FROM` plus a `RUN` that bakes a marker
11 * file into an image layer; the bundled `{ run }` program then reads that
12 * file back at container runtime and exits non-zero if it is missing or
13 * wrong. A Fargate exit code of 0 therefore proves BOTH halves of the
14 * composition: the inline content replaced the generated `FROM` preamble
15 * (the `RUN` executed during the build), and the Effect bundle was layered
16 * on top of that environment (the program ran inside it).
17 */
18 export class InlineDockerfileTask extends Task<InlineDockerfileTask>()("EcsInlineDockerfileTask") {}
19
20 export default InlineDockerfileTask.make(
21 {
22 main: import.meta.filename,
23 dockerfile: Dockerfile.inline`
24 FROM oven/bun:1
25 RUN echo inline-env-artifact > /inline-artifact.txt
26 `,
27 cpu: 256,
28 memory: 512,
29 // Build/run on ARM64 so an image built on an Apple Silicon host matches
30 // the Fargate runtime architecture (Graviton).
31 runtimePlatform: {
32 cpuArchitecture: "ARM64",
33 operatingSystemFamily: "LINUX",
34 },
35 taskName: "alchemy-test-ecs-inline-dockerfile",
36 },
37 Effect.gen(function* () {
38 const fs = yield* FileSystem.FileSystem;
39 return {
40 run: Effect.gen(function* () {
41 const artifact = yield* fs.readFileString("/inline-artifact.txt");
42 if (artifact.trim() !== "inline-env-artifact") {
43 return yield* Effect.die(new Error(`unexpected artifact content: ${artifact}`));
44 }
45 yield* Effect.log("alchemy-inline-dockerfile-artifact-ok");
46 }).pipe(Effect.orDie),
47 };
48 }),
49 );