Skip to content

Setup

Everything you need before deploying to DigitalOcean: the packages, a team, and a personal access token stored in a profile.

Terminal window
mkdir my-app && cd my-app && pnpm init
Terminal window
pnpm add https://pkg.alchemy.run/alchemy/pr:3743:41147c9 https://pkg.alchemy.run/@alchemy.run/digitalocean/pr:3743:41147c9 effect @effect/platform-node

Everything you create belongs to a team, and a token reaches one team. Pick the team in the control panel’s top-left menu, then:

  1. Go to API → Tokens and click Generate New Token.
  2. Choose Full Access: a Stack creates many kinds of resources.
  3. Copy the token. DigitalOcean shows it only once.

Give production its own team, and its own token, so it stays apart from everything else. See Teams, projects and tokens.

Store the token in a profile:

Terminal window
pnpm alchemy profile edit --add DigitalOcean

Alchemy asks for the token, an optional API base URL, and an optional Spaces access key pair. Leave the Spaces key empty unless you already have one: each deploy then creates a temporary key for its bucket changes and deletes it afterwards.

To store a token from an environment variable instead, without prompts:

Terminal window
pnpm alchemy profile edit --add DigitalOcean --method stored --set apiToken=env:DIGITALOCEAN_TOKEN

Check what’s stored (secrets are hidden):

Terminal window
pnpm alchemy profile show

With CI=true, Alchemy skips the profile and reads DIGITALOCEAN_TOKEN (or DIGITALOCEAN_ACCESS_TOKEN, then DIGITALOCEAN_API_KEY), an optional DIGITALOCEAN_API_BASE_URL, and an optional SPACES_ACCESS_KEY_ID and SPACES_SECRET_ACCESS_KEY. See CI.

DigitalOcean has no storage for Alchemy’s record of what each Stack created. Keep it next to your code with Alchemy.localState(), or share it with your team and CI through Cloudflare.state() or AWS.state(). See State Store.

alchemy.run.ts
import * as DigitalOcean from "@alchemy.run/digitalocean";
import * as Alchemy from "alchemy";
import * as Effect from "effect/Effect";
export default Alchemy.Stack(
"MyApp",
{ providers: DigitalOcean.providers(), state: Alchemy.localState() },
Effect.gen(function* () {
const host = yield* DigitalOcean.Droplet("Host", {
region: "nyc3",
size: "s-1vcpu-1gb",
image: "ubuntu-24-04-x64",
});
return { ip: host.ipv4 };
}),
);

Next, the tutorial builds an App step by step.