1import * as Alchemy from "alchemy";
2import * as Fly from "alchemy/Fly";
3import * as Effect from "effect/Effect";
4
5export default Alchemy.Stack(
6 "FlyAppExample",
7 {
8 providers: Fly.providers(),
9 state: Alchemy.localState(),
10 },
11 Effect.gen(function* () {
12 const site = yield* Fly.App("Site");
13 const ip = yield* Fly.IpAssignment("Shared", {
14 app: site,
15 type: "shared_v4",
16 });
17 const web = yield* Fly.Machine("Web", {
18 app: site,
19 region: "iad",
20 image: "nginx:alpine",
21 guest: { cpuKind: "shared", cpus: 1, memoryMb: 256 },
22 services: [
23 {
24 protocol: "tcp",
25 internalPort: 80,
26 ports: [
27 { port: 80, handlers: ["http"], forceHttps: true },
28 { port: 443, handlers: ["tls", "http"] },
29 ],
30 },
31 ],
32 });
33
34 return {
35 url: site.url,
36 ip: ip.ip,
37 machineId: web.machineId,
38 };
39 }),
40);