From 92b7848ee71a525dc3d73610d8a70faca35a52d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:50:05 +0000 Subject: [PATCH 1/4] chore: deploy as a Vercel Daemon Add vercel.json to run the existing Dockerfile as a single-instance Vercel Daemon, and disconnect from the Gateway on SIGTERM so the old and new instances do not overlap during a deploy. --- .dockerignore | 5 ++++- .gitignore | 4 +++- AGENTS.md | 7 +++++++ src/index.ts | 8 ++++++++ vercel.json | 11 +++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 vercel.json diff --git a/.dockerignore b/.dockerignore index 99f7c1c..2cb7424 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,4 +8,7 @@ config.json # Other .devcontainer/ .github/ -.vscode/ \ No newline at end of file +.vscode/ +# Vercel +.vercel/ +vercel.json diff --git a/.gitignore b/.gitignore index 4050f67..8ee1812 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ node_modules/ # Configuration files config.json *.env -*.ignore \ No newline at end of file +*.ignore +# Vercel +.vercel/ diff --git a/AGENTS.md b/AGENTS.md index c570666..d83d242 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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). diff --git a/src/index.ts b/src/index.ts index d4cefae..008aad9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); +}); diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..ad2aace --- /dev/null +++ b/vercel.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://openapi.vercel.sh/vercel.json", + "daemons": { + "codercord": { + "root": "./", + "entrypoint": "Dockerfile", + "instances": { "iad1": 1 }, + "resources": { "requests": { "memory": "1Gi" } } + } + } +} From 00f5b3d9153033b82aa649ecd57f6f6a3a21fdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:48:09 +0000 Subject: [PATCH 2/4] fix: give Vercel a separate output directory Vercel publishes the repo root as static files when no output directory is set, which conflicts with the daemon root. Point it to an empty public/ directory instead. --- vercel.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vercel.json b/vercel.json index ad2aace..ca415c5 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,7 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", + "buildCommand": "mkdir -p public", + "outputDirectory": "public", "daemons": { "codercord": { "root": "./", From 3072836e293d0e0ba0a92c0ae75972aa5b313b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:48:54 +0000 Subject: [PATCH 3/4] fix: put a robots.txt in the Vercel output directory Vercel refuses an empty output directory. Generate a robots.txt that disallows all crawlers, so the directory has content. --- vercel.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vercel.json b/vercel.json index ca415c5..912c80d 100644 --- a/vercel.json +++ b/vercel.json @@ -1,13 +1,19 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", - "buildCommand": "mkdir -p public", + "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" } } + "instances": { + "iad1": 1 + }, + "resources": { + "requests": { + "memory": "1Gi" + } + } } } } From 6de40a9b87df727d4ef2ec001ad492c75f9449b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:50:19 +0000 Subject: [PATCH 4/4] chore: ignore the generated Vercel output directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8ee1812..8ae3e60 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ config.json *.ignore # Vercel .vercel/ +public/