Part 1: Your First Stack
Install Alchemy, declare an Archil disk, and deploy it.
Prerequisites
Section titled “Prerequisites”Create a project
Section titled “Create a project”mkdir my-app && cd my-app && pnpm initmkdir my-app && cd my-app && bun init -ymkdir my-app && cd my-app && npm init -ymkdir my-app && cd my-app && yarn init -yInstall dependencies
Section titled “Install dependencies”pnpm add https://pkg.alchemy.run/alchemy/pr:2930:0cabab6 https://pkg.alchemy.run/@alchemy.run/archil/pr:2930:0cabab6 effect @effect/platform-nodebun add https://pkg.alchemy.run/alchemy/pr:2930:0cabab6 https://pkg.alchemy.run/@alchemy.run/archil/pr:2930:0cabab6 effect @effect/platform-nodenpm install https://pkg.alchemy.run/alchemy/pr:2930:0cabab6 https://pkg.alchemy.run/@alchemy.run/archil/pr:2930:0cabab6 effect @effect/platform-nodeyarn add https://pkg.alchemy.run/alchemy/pr:2930:0cabab6 https://pkg.alchemy.run/@alchemy.run/archil/pr:2930:0cabab6 effect @effect/platform-nodeCreate the Stack
Section titled “Create the Stack”Every Alchemy program starts with a Stack:
import * as Archil from "@alchemy.run/archil";import * as Alchemy from "alchemy";import * as Effect from "effect/Effect";
export default Alchemy.Stack( "MyApp", { providers: Archil.providers(), state: Alchemy.localState() }, Effect.gen(function* () {}),);Archil.providers() reads your key from your Alchemy profile.
Alchemy.localState() keeps deploy state in .alchemy/ next to your
code; Part 5 moves it somewhere CI can read.
Declare a disk
Section titled “Declare a disk”Declare resources in their own module so programs can import them:
import * as Archil from "@alchemy.run/archil";
export const Files = Archil.Disk("Files", {});Alchemy names the disk from the stack, stage and logical id.
Add it to the Stack
Section titled “Add it to the Stack”Yield the disk and return its id:
import * as Archil from "@alchemy.run/archil";import * as Alchemy from "alchemy";import * as Effect from "effect/Effect";import { Files } from "./src/Storage.ts";
export default Alchemy.Stack( "MyApp", { providers: Archil.providers(), state: Alchemy.localState() }, Effect.gen(function* () {}), Effect.gen(function* () { const files = yield* Files; return { diskId: files.diskId }; }),);Deploy
Section titled “Deploy”pnpm alchemy deploybun alchemy deploynpx alchemy deployyarn alchemy deployThe output prints diskId, a dsk-… id. The disk shows up under
Disks in the Archil console.
You have a Stack with one Archil disk. In Part 2 you’ll run a program that reads and writes files on it.