Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ config.json
# Other
.devcontainer/
.github/
.vscode/
.vscode/
# Vercel
.vercel/
vercel.json
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ node_modules/
# Configuration files
config.json
*.env
*.ignore
*.ignore
# Vercel
.vercel/
public/
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,10 @@ environment file -> process environment. Keys are **case-sensitive**.
Pushing to `main` triggers `.github/workflows/deploy-docker.yaml`, which
builds the `Dockerfile` (`oven/bun:1`) and publishes the image to GHCR with a
build-provenance attestation.

The bot runs on Vercel as a [Daemon](https://vercel.com/docs/daemons), declared
in `vercel.json`. Vercel builds the same `Dockerfile` on each production
deployment. Keep `instances` at exactly `1`: more than one instance makes every
Gateway event fire twice. On deploy, Vercel sends `SIGTERM` to the old
instance, and `src/index.ts` disconnects at once so the two instances do not
overlap. Secrets are project environment variables (Production scope).
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ client.once(Events.ClientReady, () => {
});

client.login(config.token);

// Disconnect at once on SIGTERM, so that the old and new instances do not
// both handle events during a deploy.
process.once("SIGTERM", async () => {
console.log("[bot]", "received SIGTERM, shutting down");
await client.destroy();
process.exit(0);
});
19 changes: 19 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "mkdir -p public && printf 'User-agent: *\\nDisallow: /\\n' > public/robots.txt",
"outputDirectory": "public",
"daemons": {
"codercord": {
"root": "./",
"entrypoint": "Dockerfile",
"instances": {
"iad1": 1
},
"resources": {
"requests": {
"memory": "1Gi"
}
}
}
}
}
Loading