Part 5: Ship to Production
So far every deploy went to your own stage. A stage is a separate copy of the whole Stack: its own App, bucket and database.
Deploy a second stage
Section titled “Deploy a second stage”pnpm alchemy deploy --stage stagingbun alchemy deploy --stage stagingnpx alchemy deploy --stage stagingyarn alchemy deploy --stage stagingEach stage gets its own resources, with the stage in their generated names. alchemy deploy without --stage keeps deploying to yours.
Give production its own team
Section titled “Give production its own team”A stage decides what you deploy; the profile’s token decides which team it goes to. Create a team for production in the control panel, a token for it, and a profile that holds that token:
pnpm alchemy profile create prodpnpm alchemy profile edit --profile prod --add DigitalOceanbun alchemy profile create prodbun alchemy profile edit --profile prod --add DigitalOceannpx alchemy profile create prodnpx alchemy profile edit --profile prod --add DigitalOceanyarn alchemy profile create prodyarn alchemy profile edit --profile prod --add DigitalOceanDeploy production
Section titled “Deploy production”pnpm alchemy deploy --stage prod --profile prodbun alchemy deploy --stage prod --profile prodnpx alchemy deploy --stage prod --profile prodyarn alchemy deploy --stage prod --profile prodProduction now has its own team: its own members, its own Container Registry and its own bill.
Share state
Section titled “Share state”Alchemy.localState() keeps Alchemy’s record on your machine, so nobody else can deploy the Stack. Before a teammate or CI deploys, move it to a shared store, like Cloudflare.state() or AWS.state(). See State Store.
Deploy from CI
Section titled “Deploy from CI”With CI=true, Alchemy skips profiles and reads the token from the DIGITALOCEAN_TOKEN environment variable. Store the production team’s token as a CI secret, expose it under that name, and run alchemy deploy --stage prod. See CI.
Tear down
Section titled “Tear down”pnpm alchemy destroy --stage stagingbun alchemy destroy --stage stagingnpx alchemy destroy --stage stagingyarn alchemy destroy --stage stagingdestroy deletes everything the stage created: the App, its image repository, the bucket and the database cluster. Run it for each stage you’re done with, and for your own when you finish this tutorial.
Where to go next
Section titled “Where to go next”- App Platform: instance sizes, scaling, alerts and more on Apps.
- Spaces: every bucket binding, CDN endpoints and keys.
- Managed Databases: users, pools, replicas and trusted sources.
- Choosing a runtime: when to use Functions, Droplets or Kubernetes instead.