doorman
To install dependencies for all packages
bun install
Packages
Check out the individual READMEs in the monorepo to see how to run each component of Doorman
- doorman-client (Twilio Function that triggers when receiving buzzer call)
- doorman-api (Twilio Function API that manages Door state and configs)
- doorman-ui (frontend React app, served by doorman-api)
- doorman-schema (future home for all the zod schemas and basic validations)
CI/CD workflows
On pushes to main, the Gitea action in .gitea/workflows/deploy-twilio.yaml handle deployments to Twilio / homeassistant.
- Builds change
- Run local integration tests
- Deploy to staging
- Run staging integration tests
- Promote to prod
.env.twiliotemplate
This file is used for twilio Deployments in github actions. In short, it specifies all the env values that are supposed to be deployed with the Function.
For any value that is specified, it uses that value.
For any value that is in the file but not specified (= nothing), it would be loaded from the execution environment (as a Gitea secret). If the env var is not in the environment passed in, then the deployment would fail.
for twilio packages, what is going on in src/index.ts (Bun.build)
This file contains a Bun bundler for Javascript. In short, it compiles the Typescript code under ./src/functions into javascript, bundling all the local files together and optionally certain dependencies.
This is necessary because Twilio Functions only supports Javascript, and doesn't allow importing code across files. This previously was really hard to maintain, because Javascript is not typed and the files were really long. Our deployed code is basically the package compiled into one file so it can be deployed in Twilio.
Also, since Bun supports ESM (import . from .) and CommonJS (require) module syntax but Twilio only supports CommonJS, the bundler will explicitly bundle dependencies that only support CommonJS. This is because when deployed in Twilio, we cannot use ESM and Bun handles this conversion for us without the library needing dual support (though most libraries support both ESM and CommonJS).
If we add a library that only supports ESM, then we need to add it as an explicitly bundled dep in src/index.ts
To deploy manually (not reccomended)
First you need to have Twilio secrets in your env
export ACCOUNT_SID=AC...
export AUTH_TOKEN=8e...
to deploy Doorman API / UI manually
bun run deploy-serverless<:staging>
to deploy Doorman Buzzer client
bun run deploy-buzzer-client<:staging>