Skip to content

Commit 2449c2d

Browse files
committed
Deploy docs
1 parent 9eab029 commit 2449c2d

File tree

6 files changed

+770
-0
lines changed

6 files changed

+770
-0
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"followees",
5555
"halfyear",
5656
"hongminhee",
57+
"HSTS",
5758
"inlines",
5859
"linkify",
5960
"logtape",

docs/.vitepress/config.mts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ const concepts = {
4040
],
4141
};
4242

43+
const deploy = {
44+
text: "Deploy",
45+
items: [
46+
{ text: "Store and message queue", link: "/deploy/store-mq.md" },
47+
{ text: "Deno Deploy", link: "/deploy/deno-deploy.md" },
48+
{ text: "Docker", link: "/deploy/docker.md" },
49+
{ text: "Self-hosting", link: "/deploy/self-hosting.md" },
50+
],
51+
};
52+
4353
// https://vitepress.dev/reference/site-config
4454
export default defineConfig({
4555
title: "BotKit by Fedify",
@@ -52,6 +62,7 @@ export default defineConfig({
5262
{ text: "About", link: "/intro.md" },
5363
{ text: "Start", link: "/start.md" },
5464
concepts,
65+
deploy,
5566
{ text: "Recipes", link: "/recipes.md" },
5667
{ text: "Examples", link: "/examples.md" },
5768
],
@@ -60,6 +71,7 @@ export default defineConfig({
6071
{ text: "What is BotKit?", link: "/intro.md" },
6172
{ text: "Getting started", link: "/start.md" },
6273
concepts,
74+
deploy,
6375
{ text: "Recipes", link: "/recipes.md" },
6476
{ text: "Examples", link: "/examples.md" },
6577
{ text: "Changelog", link: "/changelog.md" },

docs/deploy/deno-deploy.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
description: >-
3+
Learn how to deploy your BotKit bot to Deno Deploy, a serverless hosting
4+
platform for Deno applications.
5+
---
6+
7+
Deno Deploy
8+
===========
9+
10+
[Deno Deploy] is a serverless hosting platform for Deno applications. It allows
11+
you to deploy your bot without managing servers or infrastructure. This guide
12+
shows you how to deploy your BotKit bot to Deno Deploy.
13+
14+
[Deno Deploy]: https://deno.com/deploy
15+
16+
17+
Prerequisites
18+
-------------
19+
20+
1. [Create a Deno Deploy account][1]
21+
22+
2. [Install the Deno CLI][2] if you haven't already
23+
24+
3. [Install `deployctl`][3]:
25+
26+
~~~~ sh
27+
deno install -gArf jsr:@deno/deployctl
28+
~~~~
29+
30+
4. Install the [Fedify] package to your bot project:
31+
32+
~~~~ sh
33+
deno add jsr:@fedify/fedify
34+
~~~~
35+
36+
5. Configure your bot to use Deno KV for storage and message queue:
37+
38+
~~~~ typescript
39+
import { createBot } from "@fedify/botkit";
40+
import { DenoKvMessageQueue, DenoKvStore } from "@fedify/fedify/x/deno";
41+
42+
const kv = await Deno.openKv();
43+
44+
const bot = createBot<void>({
45+
username: "mybot",
46+
kv: new DenoKvStore(kv),
47+
queue: new DenoKvMessageQueue(kv),
48+
// ... other configuration
49+
});
50+
~~~~
51+
52+
[1]: https://dash.deno.com/login
53+
[2]: https://docs.deno.com/runtime/getting_started/installation/
54+
[3]: https://docs.deno.com/deploy/manual/deployctl/#install-deployctl
55+
[Fedify]: https://fedify.dev/
56+
57+
58+
Deploying your bot
59+
------------------
60+
61+
1. Navigate to your project directory
62+
63+
2. Deploy your bot:
64+
65+
~~~~ sh
66+
deployctl deploy
67+
~~~~
68+
69+
On the first deployment, `deployctl` will:
70+
71+
- Guess the project name from your Git repo or directory name
72+
- Create the project automatically if it doesn't exist
73+
- Look for common entrypoint files like *main.ts* or *src/main.ts*
74+
75+
You can also specify these explicitly:
76+
77+
~~~~ sh
78+
deployctl deploy --project=mybot --entrypoint=bot.ts
79+
~~~~
80+
81+
3. Set up your custom domain in the Deno Deploy dashboard (optional)
82+
83+
84+
Environment variables
85+
---------------------
86+
87+
You can set environment variables in multiple ways:
88+
89+
- During deployment using the `--env` flag:
90+
91+
~~~~ sh
92+
deployctl deploy --env=SERVER_NAME=mybot.deno.dev
93+
~~~~
94+
95+
- Using an environment file:
96+
97+
~~~~ sh
98+
deployctl deploy --env-file=.env
99+
~~~~
100+
101+
- Or configure them in the Deno Deploy dashboard for project-wide settings
102+
103+
Common variables include:
104+
105+
- `SERVER_NAME`: Your bot's domain (e.g., `mybot.deno.dev`)
106+
- Other bot-specific configuration variables
107+
108+
<!-- cSpell: ignore deployctl mybot -->

docs/deploy/docker.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
description: >-
3+
Learn how to deploy your BotKit bot using Docker containers on platforms like
4+
Fly.io and Railway.
5+
---
6+
7+
Docker
8+
======
9+
10+
Docker containers provide a consistent deployment environment and can be hosted
11+
on various platforms like [Fly.io], [Railway], or any container hosting service.
12+
13+
[Fly.io]: https://fly.io/
14+
[Railway]: https://railway.com/
15+
16+
17+
Creating a *Dockerfile*
18+
-----------------------
19+
20+
Create a *Dockerfile* in your project root:
21+
22+
~~~~ dockerfile [Dockerfile]
23+
FROM denoland/deno:2.1.9
24+
25+
WORKDIR /app
26+
27+
# Cache dependencies
28+
COPY deno.json deno.json
29+
COPY deno.lock deno.lock
30+
RUN deno install
31+
32+
# Copy source code
33+
COPY . .
34+
35+
# The bot needs network access and environment variables
36+
ENV SERVER_NAME=your-domain.com
37+
38+
# Run the bot
39+
CMD ["deno", "run", "-A", "bot.ts"]
40+
~~~~
41+
42+
43+
Deploying to [Fly.io]
44+
---------------------
45+
46+
1. Install the [Fly.io CLI]
47+
48+
2. Initialize your Fly.io app:
49+
50+
~~~~ bash
51+
fly launch
52+
~~~~
53+
54+
3. Configure environment variables:
55+
56+
~~~~ bash
57+
fly secrets set SERVER_NAME=your-domain.com
58+
~~~~
59+
60+
4. Deploy your app:
61+
62+
~~~~ bash
63+
fly deploy
64+
~~~~
65+
66+
[Fly.io CLI]: https://fly.io/docs/flyctl/
67+
68+
69+
Deploying to [Railway]
70+
----------------------
71+
72+
1. Create a new project on [Railway]
73+
74+
2. Connect your GitHub repository
75+
76+
3. Configure environment variables in the Railway dashboard
77+
78+
4. Railway will automatically build and deploy your container
79+
80+
<!-- cSpell: ignore denoland -->

0 commit comments

Comments
 (0)