Skip to content

Commit 79624c1

Browse files
authored
Update self-hosting docs (#1354)
* add docker only note * add support section * add large payloads section * additional features section and misc updates * troubleshooting section * add auth section * skip default pr checks for docs changes * minor changes
1 parent c063dad commit 79624c1

File tree

2 files changed

+113
-22
lines changed

2 files changed

+113
-22
lines changed

.github/workflows/pr_checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: 🤖 PR Checks
33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
6+
paths-ignore:
7+
- "docs/**"
68

79
concurrency:
810
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

docs/open-source-self-hosting.mdx

Lines changed: 111 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ title: "Self-hosting"
33
description: "You can self-host Trigger.dev on your own infrastructure."
44
---
55

6+
<Note>This guide is for Docker only. We don't currently provide documentation for Kubernetes.</Note>
7+
68
## Overview
79

810
<Frame>
911
<img src="/images/self-hosting.png" alt="Self-hosting architecture" />
1012
</Frame>
1113

12-
The self-hosting guide comes in two parts. The first part is a simple setup where you run everything on one server. In the second part, the webapp and worker components are split on two separate machines.
14+
The self-hosting guide covers two alternative setups. The first option uses a simple setup where you run everything on one server. With the second option, the webapp and worker components are split on two separate machines.
1315

1416
You're going to need at least one Debian (or derivative) machine with Docker and Docker Compose installed. We'll also use Ngrok to expose the webapp to the internet.
1517

18+
## Support
19+
20+
It's dangerous to go alone! Join the self-hosting channel on our [Discord server](https://discord.gg/NQTxt5NA7s).
21+
1622
## Caveats
1723

1824
<Note>The v3 worker components don't have ARM support yet.</Note>
@@ -49,7 +55,7 @@ Should the burden ever get too much, we'd be happy to see you on [Trigger.dev cl
4955

5056
You will also need a way to expose the webapp to the internet. This can be done with a reverse proxy, or with a service like Ngrok. We will be using the latter in this guide.
5157

52-
## Part 1: Single server
58+
## Option 1: Single server
5359

5460
This is the simplest setup. You run everything on one server. It's a good option if you have spare capacity on an existing machine, and have no need to independently scale worker capacity.
5561

@@ -161,55 +167,126 @@ DEPLOY_REGISTRY_NAMESPACE=<your_dockerhub_username>
161167
3. Log in to Docker Hub both locally and your server. For the split setup, this will be the worker machine. You may want to create an [access token](https://hub.docker.com/settings/security) for this.
162168

163169
```bash
164-
docker login -u <your_dockerhub_username>
170+
docker login -u <your_dockerhub_username> docker.io
171+
```
172+
173+
4. Required on some systems: Run the login command inside the `docker-provider` container so it can pull deployment images to run your tasks.
174+
175+
```bash
176+
docker exec -ti \
177+
trigger-docker-provider-1 \
178+
docker login -u <your_dockerhub_username> docker.io
165179
```
166180

167-
4. Restart the services
181+
5. Restart the services
168182

169183
```bash
170184
./stop.sh && ./start.sh
171185
```
172186

173-
5. You can now deploy v3 projects using the CLI with these flags:
187+
6. You can now deploy v3 projects using the CLI with these flags:
174188

175189
```
176190
npx trigger.dev@latest deploy --self-hosted --push
177191
```
178192

179-
## Part 2: Split services
193+
## Option 2: Split services
180194

181195
With this setup, the webapp will run on a different machine than the worker components. This allows independent scaling of your workload capacity.
182196

183197
### Webapp setup
184198

185-
All steps are the same as in Part 1, except for the following:
199+
All steps are the same as for a single server, except for the following:
186200

187-
1. Run the start script with the `webapp` argument
201+
1. **Startup.** Run the start script with the `webapp` argument
188202

189203
```bash
190204
./start.sh webapp
191205
```
192206

193-
2. Tunnelling is now _required_. Please follow the tunnelling section from above.
207+
2. **Tunnelling.** This is now _required_. Please follow the [tunnelling](/open-source-self-hosting#tunnelling) section.
194208

195209
### Worker setup
196210

197-
1. Copy your `.env` file from the webapp to the worker machine
211+
1. **Environment variables.** Copy your `.env` file from the webapp to the worker machine:
198212

199213
```bash
200214
# an example using scp
201215
scp -3 root@<webapp_machine>:docker/.env root@<worker_machine>:docker/.env
202216
```
203217

204-
2. Run the start script with the `worker` argument
218+
2. **Startup.** Run the start script with the `worker` argument
205219

206220
```bash
207221
./start.sh worker
208222
```
209223

210-
2. Tunnelling is _not_ required for the worker components.
224+
3. **Tunnelling.** This is _not_ required for the worker components.
225+
226+
4. **Registry setup.** Follow the [registry setup](/open-source-self-hosting#registry-setup) section but run the last command on the worker machine - note the container name is different:
227+
228+
```bash
229+
docker exec -ti \
230+
trigger-worker-docker-provider-1 \
231+
docker login -u <your_dockerhub_username> docker.io
232+
```
233+
234+
## Additional features
235+
236+
### Large payloads
237+
238+
By default, payloads over 512KB will be offloaded to S3-compatible storage. If you don't provide the required env vars, runs with payloads larger than this will fail.
239+
240+
For example, using Cloudflare R2:
241+
242+
```bash
243+
OBJECT_STORE_BASE_URL="https://<bucket>.<account>.r2.cloudflarestorage.com"
244+
OBJECT_STORE_ACCESS_KEY_ID="<r2 access key with read/write access to bucket>"
245+
OBJECT_STORE_SECRET_ACCESS_KEY="<r2 secret key>"
246+
```
247+
248+
Alternatively, you can increase the threshold:
249+
250+
```bash
251+
# size in bytes, example with 5MB threshold
252+
TASK_PAYLOAD_OFFLOAD_THRESHOLD=5242880
253+
```
254+
255+
### Version locking
256+
257+
There are several reasons to lock the version of your Docker images:
258+
- **Backwards compatibility.** We try our best to maintain compatibility with older CLI versions, but it's not always possible. If you don't want to update your CLI, you can lock your Docker images to that specific version.
259+
- **Ensuring full feature support.** Sometimes, new CLI releases will also require new or updated platform features. Running unlocked images can make any issues difficult to debug. Using a specific tag can help here as well.
260+
261+
By default, the images will point at the latest versioned release via the `v3` tag. You can override this by specifying a different tag in your `.env` file. For example:
262+
263+
```bash
264+
TRIGGER_IMAGE_TAG=v3.0.4
265+
```
266+
267+
### Auth options
268+
269+
By default, magic link auth is the only login option. If the `RESEND_API_KEY` env var is not set, the magic links will be logged by the webapp container and not sent via email.
270+
271+
All email addresses can sign up and log in this way. If you would like to restrict this, you can use the `WHITELISTED_EMAILS` env var. For example:
272+
273+
```bash
274+
# every email that does not match this regex will be rejected
275+
WHITELISTED_EMAILS="authorized@yahoo\.com|authorized@gmail\.com"
276+
```
277+
278+
It's currently impossible to restrict GitHub OAuth logins by account name or email like above, so this method is _not recommended_ for self-hosted instances. It's also very easy to lock yourself out of your own instance.
279+
280+
<Warning>Only enable GitHub auth if you understand the risks! We strongly advise you against this.</Warning>
211281

212-
## Checkpoint support
282+
Your GitHub OAuth app needs a callback URL `https://<your_domain>/auth/github/callback` and you will have to set the following env vars:
283+
284+
```bash
285+
AUTH_GITHUB_CLIENT_ID=<your_client_id>
286+
AUTH_GITHUB_CLIENT_SECRET=<your_client_secret>
287+
```
288+
289+
### Checkpoint support
213290

214291
<Warning>
215292
This requires an _experimental Docker feature_. Successfully checkpointing a task today, does not
@@ -219,14 +296,14 @@ scp -3 root@<webapp_machine>:docker/.env root@<worker_machine>:docker/.env
219296
Checkpointing allows you to save the state of a running container to disk and restore it later. This can be useful for
220297
long-running tasks that need to be paused and resumed without losing state. Think fan-out and fan-in, or long waits in email campaigns.
221298

222-
The checkpoints will be pushed to the same registry as the deployed images. Please see the [Registry setup](#registry-setup) section for more information.
299+
The checkpoints will be pushed to the same registry as the deployed images. Please see the [registry setup](#registry-setup) section for more information.
223300

224-
### Requirements
301+
#### Requirements
225302

226303
- Debian, **NOT** a derivative like Ubuntu
227304
- Additional storage space for the checkpointed containers
228305

229-
### Setup
306+
#### Setup
230307

231308
Underneath the hood this uses Checkpoint and Restore in Userspace, or [CRIU](https://github.com/checkpoint-restore/criu) in short. We'll have to do a few things to get this working:
232309

@@ -329,16 +406,28 @@ git stash pop
329406
./stop.sh && ./start.sh
330407
```
331408

332-
## Version locking
409+
## Troubleshooting
333410

334-
There are several reasons to lock the version of your Docker images:
335-
- **Backwards compatibility.** We try our best to maintain compatibility with older CLI versions, but it's not always possible. If you don't want to update your CLI, you can lock your Docker images to that specific version.
336-
- **Ensuring full feature support.** Sometimes, new CLI releases will also require new or updated platform features. Running unlocked images can make any issues difficult to debug. Using a specific tag can help here as well.
411+
- **Deployment fails at the push step.** The machine running `deploy` needs registry access:
337412

338-
By default, the images will point at the latest versioned release via the `v3` tag. You can override this by specifying a different tag in your `.env` file. For example:
413+
```bash
414+
docker login -u <username> <registry>
415+
# this should now succeed
416+
npx trigger.dev@latest deploy --self-hosted --push
417+
```
418+
419+
- **Prod runs fail to start.** The `docker-provider` needs registry access:
339420

340421
```bash
341-
TRIGGER_IMAGE_TAG=v3.0.4
422+
# single server? run this:
423+
docker exec -ti \
424+
trigger-docker-provider-1 \
425+
docker login -u <your_dockerhub_username> docker.io
426+
427+
# split webapp and worker? run this on the worker:
428+
docker exec -ti \
429+
trigger-worker-docker-provider-1 \
430+
docker login -u <your_dockerhub_username> docker.io
342431
```
343432

344433
## CLI usage

0 commit comments

Comments
 (0)