Skip to content

Commit b29ef93

Browse files
committed
couple of changes
1 parent af7a2e6 commit b29ef93

File tree

5 files changed

+219
-86
lines changed

5 files changed

+219
-86
lines changed

docs/self-hosting/docker.mdx

Lines changed: 125 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ Should the burden ever get too much, we'd be happy to see you on [Trigger.dev cl
1414
## What's new?
1515

1616
Goodbye v3, hello v4! We made quite a few changes:
17-
- **Much simpler setup.** Provider + coordinator = supervisor. No more startup scripts. Just `docker compose up`.
17+
- **Much simpler setup.** The provider and coordinator are now combined into a single supervisor. No more startup scripts, just `docker compose up`.
18+
- **Automatic container cleanup.** The supervisor will automatically clean up containers that are no longer needed.
1819
- **Support for multiple worker machines.** This is a big one, and we're very excited about it! You can now scale your workers horizontally as needed.
1920
- **Resource limits enforced by default.** This means that tasks will be limited to the total CPU and RAM of the machine preset, preventing noisy neighbours.
2021
- **No direct Docker socket access.** The compose file now comes with [Docker Socket Proxy](https://github.com/Tecnativa/docker-socket-proxy) by default. Yes, you want this.
2122
- **No host networking.** All containers are now running with network isolation, using only the network access they need.
22-
- **No checkpoint support.** This was only ever an experimental self-hosting feature and not recommended. It caused a bunch of issues. We decided to focus on the core features instead.
23+
- **No checkpoint support.** This was only ever experimental when self-hosting and not recommended. It caused a bunch of issues. We decided to focus on the core features instead.
2324
- **Built-in container registry and object storage.** You can now deploy and execute tasks without needing third party services for this.
24-
- **Improved CLI commands.** You don't need any additional flags to deploy anymore, and there's a new `switch` command to easily switch between profiles.
25+
- **Improved CLI commands.** You don't need any additional flags to deploy anymore, and there's a new command to easily `switch` between profiles.
2526
- **Whitelisting for GitHub OAuth.** Any whitelisted email addresses will now also apply to sign ins via GitHub, unlike v3 where they only applied to magic links.
2627

2728
## Requirements
@@ -39,14 +40,14 @@ To run the webapp and worker components, you will need:
3940

4041
### Webapp
4142

42-
This will host the webapp, postgres, redis, and related services.
43+
This machine will host the webapp, postgres, redis, and related services.
4344

4445
- 2+ vCPU
4546
- 4+ GB RAM
4647

4748
### Worker
4849

49-
This will host the supervisor and all of the runs.
50+
This machine will host the supervisor and all of the runs.
5051

5152
- 2+ vCPU
5253
- 4+ GB RAM
@@ -86,26 +87,30 @@ cd webapp
8687
docker compose up -d
8788
```
8889

89-
4. Optional: Add traefik as a reverse proxy
90+
4. Configure the webapp using the [environment variables](/self-hosting/env/webapp) in your `.env` file, then apply the changes:
9091

9192
```bash
92-
docker compose -f ../docker-compose.traefik.yml up -d
93+
docker compose up -d
9394
```
9495

95-
5. Configure the webapp as needed using the [environment variables](/self-hosting/env/webapp) and apply the changes:
96+
5. You should now be able to access the webapp at `http://localhost:8030`. When logging in, check the container logs for the magic link:
9697

9798
```bash
98-
docker compose up -d
99+
docker compose logs -f webapp
99100
```
100101

101-
6. You should now be able to access the webapp at `http://localhost:8030`. When logging in, check the container logs for the magic link: `docker compose logs -f webapp`
102-
103-
7. Optional: To initialize a new project, run the following command:
102+
6. (optional) To initialize a new project, run the following command:
104103

105104
```bash
106105
npx trigger.dev@v4-beta init -p <project-ref> -a http://localhost:8030
107106
```
108107

108+
{/* 7. Bonus: Add traefik as a reverse proxy
109+
110+
```bash
111+
docker compose -f docker-compose.yml -f ../docker-compose.traefik.yml up -d
112+
``` */}
113+
109114
### Worker
110115

111116
1. Clone the repository
@@ -128,50 +133,125 @@ cd worker
128133
docker compose up -d
129134
```
130135

131-
Configure the supervisor as needed using the [environment variables](/self-hosting/env/supervisor) and apply the changes:
136+
4. Configure the supervisor using the [environment variables](/self-hosting/env/supervisor) in your `.env` file, including the [worker token](#worker-token).
137+
138+
5. Apply the changes:
132139

133140
```bash
134141
docker compose up -d
135142
```
136143

137-
Repeat as needed for additional workers.
144+
6. Repeat as needed for additional workers.
138145

139146
### Combined
140147

141148
If you want to run the webapp and worker on the same machine, just replace the `up` command with the following:
142149

143150
```bash
144151
# Run this from the /hosting/docker directory
145-
docker compose -f docker-compose.webapp.yml -f docker-compose.worker.yml up -d
152+
docker compose -f webapp/docker-compose.yml -f worker/docker-compose.yml up -d
146153
```
147154

148-
And optionally add traefik as a reverse proxy:
155+
{/* And optionally add traefik as a reverse proxy:
149156
150157
```bash
151158
# Run this from the /hosting/docker directory
152-
docker compose -f docker-compose.webapp.yml -f docker-compose.worker.yml -f docker-compose.traefik.yml up -d
159+
docker compose -f webapp/docker-compose.yml -f worker/docker-compose.yml -f docker-compose.traefik.yml up -d
160+
``` */}
161+
162+
## Worker token
163+
164+
When running the combined stack, worker bootstrap is handled automatically. When running the webapp and worker separately, you will need to manually set the worker token.
165+
166+
On the first run, the webapp will generate a worker token and store it in a shared volume. It will also print the token to the console. It should look something like this:
167+
168+
```bash
169+
==========================
170+
Trigger.dev Bootstrap - Worker Token
171+
172+
WARNING: This will only be shown once. Save it now!
173+
174+
Worker group:
175+
bootstrap
176+
177+
Token:
178+
tr_wgt_fgfAEjsTmvl4lowBLTbP7Xo563UlnVa206mr9uW6
179+
180+
If using docker compose, set:
181+
TRIGGER_WORKER_TOKEN=tr_wgt_fgfAEjsTmvl4lowBLTbP7Xo563UlnVa206mr9uW6
182+
183+
Or, if using a file:
184+
TRIGGER_WORKER_TOKEN=file:///home/node/shared/worker_token
185+
186+
==========================
153187
```
154188
155-
## Version locking
189+
You can then uncomment and set the `TRIGGER_WORKER_TOKEN` environment variable in your `.env` file.
156190
157-
There are several reasons to lock the version of your Docker images:
158-
- **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.
159-
- **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.
191+
Don't forget to restart the worker container for the changes to take effect:
160192
161-
By default, the images will point at the latest versioned release via the `v4-beta` tag. You can override this by specifying a different tag in your `.env` file. For example:
193+
```bash
194+
# Run this from the /hosting/docker/worker directory
195+
docker compose down
196+
docker compose up -d
197+
```
198+
199+
## Registry setup
200+
201+
The registry is used to store and pull deployment images. When testing the stack locally, the defaults should work out of the box.
202+
203+
When deploying to production, you will need to set the correct URL and generate secure credentials for the registry.
204+
205+
### Default settings
206+
207+
The default settings for the registry are:
208+
209+
- Registry: `localhost:5000`
210+
- Username: `registry-user`
211+
- Password: `very-secure-indeed`
212+
213+
You should change these before deploying to production, especially the password. You can find more information about how to do this in the official [registry docs](https://github.com/distribution/distribution/blob/735c161b53e7faf81a21ba94c55ac9edee081cd9/docs/deploying.md#native-basic-auth).
214+
215+
### Logging in
216+
217+
When self-hosting, builds run locally. You will have to login to the registry on every machine that runs the `deploy` command. You should only have to do this once:
162218
163219
```bash
164-
TRIGGER_IMAGE_TAG=v4.0.0-v4-beta.21
220+
docker login -u <username> <registry>
165221
```
166222
223+
This will prompt for the password. Afterwards, the deploy command should work as expected.
224+
225+
## Object storage
226+
227+
This is mainly used for large payloads and outputs. There are a few simple steps to follow to get started.
228+
229+
### Default settings
230+
231+
The default settings for the object storage are:
232+
233+
- Endpoint: `http://localhost:9000`
234+
- Username: `admin`
235+
- Password: `very-safe-password`
236+
237+
You should change these before deploying to production, especially the password.
238+
239+
### Setup
240+
241+
1. Login to the dashboard: `http://localhost:9001`
242+
243+
2. Create a bucket named `packets`.
244+
245+
3. For production, you will want to set up a dedicated user and not use the root credentials above.
246+
167247
## Authentication
168248
249+
The specific set of variables required will depend on your choice of email transport or alternative login methods like GitHub OAuth.
250+
169251
### Magic link
170252
171253
By default, magic link auth is the only login option. If the `EMAIL_TRANSPORT` env var is not set, the magic links will be logged by the webapp container and not sent via email.
172254
173-
The specific set of variables required will depend on your choice of email transport.
174-
175255
#### Resend
176256
177257
```bash
@@ -228,23 +308,32 @@ All email addresses can sign up and log in this way. If you would like to restri
228308
WHITELISTED_EMAILS="authorized@yahoo\.com|authorized@gmail\.com"
229309
```
230310
231-
This will apply to all auth methods.
311+
This will apply to all auth methods including magic link and GitHub OAuth.
232312
233-
## Troubleshooting
313+
## Version locking
234314
235-
- **Deployment fails at the push step.** The machine running `deploy` needs registry access:
315+
There are several reasons to lock the version of your Docker images:
316+
- **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.
317+
- **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.
318+
319+
By default, the images will point at the latest versioned release via the `v4-beta` tag. You can override this by specifying a different tag in your `.env` file. For example:
236320
237321
```bash
238-
docker login -u <username> <registry>
239-
# this should now succeed
240-
npx trigger.dev@v4-beta deploy
322+
TRIGGER_IMAGE_TAG=v4.0.0-v4-beta.21
241323
```
242324
243-
This needs to match the registry credentials. Defaults for the `localhost:5000` registry are `registry-user` and `very-safe-password`. You should change these.
325+
## Troubleshooting
326+
327+
- **Deployment fails at the push step.** The machine running `deploy` needs registry access. See the [registry setup](#registry-setup) section for more details.
244328
245329
- **Magic links don't arrive.** The webapp container needs to be able to send emails. You probably need to set up an email transport. See the [authentication](#authentication) section for more details.
246330
247-
You should check the logs of the webapp container to see the magic link: `docker logs -f trigger-webapp-1`
331+
You should check the logs of the webapp container to see the magic link:
332+
333+
```bash
334+
# Run this from the /hosting/docker/webapp directory
335+
docker compose logs -f webapp
336+
```
248337
249338
## CLI usage
250339
@@ -260,7 +349,7 @@ npx trigger.dev@v4-beta login -a http://trigger.example.com
260349
261350
Once you've logged in, you shouldn't have to specify the URL again with other commands.
262351
263-
#### Profiles
352+
### Profiles
264353
265354
You can specify a profile when logging in. This allows you to easily use the CLI with multiple instances of Trigger.dev. For example:
266355
@@ -299,15 +388,15 @@ npx trigger.dev@v4-beta switch
299388
npx trigger.dev@v4-beta switch self-hosted
300389
```
301390
302-
#### Whoami
391+
### Whoami
303392
304393
It can be useful to check you are logged into the correct instance. Running this will also show the API URL:
305394
306395
```bash
307396
npx trigger.dev@v4-beta whoami
308397
```
309398
310-
### CI / GitHub Actions
399+
## CI / GitHub Actions
311400
312401
When running the CLI in a CI environment, your login profiles won't be available. Instead, you can use the `TRIGGER_API_URL` and `TRIGGER_ACCESS_TOKEN` environment
313402
variables to point at your self-hosted instance and authenticate.

docs/self-hosting/env/webapp.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mode: "wide"
126126
| `RUN_ENGINE_RATE_LIMIT_LIMITER_LOGS_ENABLED` | No | 0 | Run engine rate limit limiter logs. |
127127
| **Misc** | | | |
128128
| `TRIGGER_TELEMETRY_DISABLED` | No || Disable telemetry. |
129-
| `NODE_MAX_OLD_SPACE_SIZE` | No | | Maximum memory allocation for Node.js heap (e.g. "4096" for 4GB). |
129+
| `NODE_MAX_OLD_SPACE_SIZE` | No | 8192 | Maximum memory allocation for Node.js heap in MiB (e.g. "4096" for 4GB). |
130130
| `OPENAI_API_KEY` | No || OpenAI API key. |
131131
| `MACHINE_PRESETS_OVERRIDE_PATH` | No || Path to machine presets override file. See [machine overrides](/self-hosting/overview#machine-overrides). |
132132
| `APP_ENV` | No | `NODE_ENV` | App environment. Used for things like the title tag. |

0 commit comments

Comments
 (0)