Starting point for new projects
- Create
.env.alchemyfor alchemy specific environment variables.
touch .env.alchemy
Add these values inside. Both are required for Alchemy to work properly.
# I like to gen both of these w/ `openssl rand -base64 32`, don't lose them!
ALCHEMY_STATE_TOKEN="xyz-123"
ALCHEMY_SECRET_PASSWORD="xyz-123"
- Create
.env.${stage}file for every stage you plan to run app in (including local - which will be the output of thewhoamicommand). These files will be used for environment variables your application(s) need access to.
touch .env.$(whoami)
touch .env.staging
touch .env.production
Any app (or infra) that has an alchemy.run.ts file should also contain scripts for deploy, destroy, and dev.
The "base" app name is up to you. I prefer to match this with whatever the name is in my root package.json
"scripts": {
...
"dev": "alchemy dev --app {APP_NAME_HERE}",
"deploy:staging": "alchemy deploy --app {APP_NAME_HERE} --stage staging",
"deploy:production": "alchemy deploy --app {APP_NAME_HERE} --stage production",
"deploy:another-cool-stage": "alchemy deploy --app {APP_NAME_HERE} --stage another-cool-stage",
"destroy:staging": "alchemy destroy --app {APP_NAME_HERE} --stage staging",
"destroy:production": "alchemy destroy --app {APP_NAME_HERE} --stage production",
}
If you have multiple Cloudflare accounts, configure a new profile in alchemy and make sure to configure the app to use said profile
In packages/infra/src/util.ts, modify the createApp() function to use the profile you want.
...
const app = await alchemy(appName, {
profile: "default", // change me, if you want!
password: process.env.ALCHEMY_SECRET_PASSWORD,
stateStore: (scope) => getSharedStateStore(scope),
});
...
bun turbo gen