Skip to content

Commit 15c6d45

Browse files
committed
docker draft
1 parent 19fbad5 commit 15c6d45

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed

docs/self-hosting/docker.mdx

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,186 @@ This guide will use docker compose to spin up a Trigger.dev instance. Make sure
1111
We've split the compose files into Webapp and Worker components so you can easily run them independently. This will also allow you to scale your workers as needed.
1212

1313
**Warning:** This guide alone is unlikely to result in a production-ready deployment. Security, scaling, and reliability concerns are not fully addressed here.
14+
15+
## Caveats
16+
17+
As self-hosted deployments tend to have unique requirements and configurations, we don't provide specific advice for securing your deployment, scaling up, or improving reliability.
18+
19+
Should the burden ever get too much, we'd be happy to see you on [Trigger.dev cloud](https://trigger.dev/pricing) where we deal with these concerns for you.
20+
21+
## Comparison with v3
22+
23+
We made quite a few changes:
24+
- **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.
25+
- **Resource limits enforced by default.** This means that tasks will be limited to the total CPU and RAM of the machine, preventing noisy neighbours.
26+
- **No direct Docker socket access.** The compose file now comes with [Docker Socket Proxy](https://github.com/Tecnativa/docker-socket-proxy) by default.
27+
- **No host networking.** All containers are now running with network isolation, using only the network access they need.
28+
- **No checkpoint support.** This was only ever an experimental feature and not recommended, it caused a bunch of issues. We decided to focus on the core features and remove it.
29+
- **Built-in container registry and object storage.** You can now deploy and execute tasks without needing third party services for this.
30+
- **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.
31+
32+
{/* TODO: requirements */}
33+
34+
{/* TODO: setup */}
35+
36+
{/* TODO: multiple workers */}
37+
38+
{/* TODO: Upgrading from v3 */}
39+
40+
## Version locking
41+
42+
There are several reasons to lock the version of your Docker images:
43+
- **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.
44+
- **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.
45+
46+
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:
47+
48+
```bash
49+
TRIGGER_IMAGE_TAG=v4.0.0-v4-beta.21
50+
```
51+
52+
## Authentication
53+
54+
### Magic link
55+
56+
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.
57+
58+
The specific set of variables required will depend on your choice of email transport.
59+
60+
#### Resend
61+
62+
```bash
63+
EMAIL_TRANSPORT=resend
64+
FROM_EMAIL=
65+
REPLY_TO_EMAIL=
66+
RESEND_API_KEY=<your_resend_api_key>
67+
```
68+
69+
#### SMTP
70+
71+
Note that setting `SMTP_SECURE=false` does _not_ mean the email is sent insecurely.
72+
This simply means that the connection is secured using the modern STARTTLS protocol command instead of implicit TLS.
73+
You should only set this to true when the SMTP server host directs you to do so (generally when using port 465)
74+
75+
```bash
76+
EMAIL_TRANSPORT=smtp
77+
FROM_EMAIL=
78+
REPLY_TO_EMAIL=
79+
SMTP_HOST=<your_smtp_server>
80+
SMTP_PORT=587
81+
SMTP_SECURE=false
82+
SMTP_USER=<your_smtp_username>
83+
SMTP_PASSWORD=<your_smtp_password>
84+
```
85+
86+
#### AWS SES
87+
88+
Credentials are to be supplied as with any other program using the AWS SDK.
89+
90+
In this scenario, you would likely either supply the additional environment variables `AWS_REGION`, `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` or, when running on AWS, use credentials supplied by the EC2 IMDS.
91+
92+
```bash
93+
EMAIL_TRANSPORT=aws-ses
94+
FROM_EMAIL=
95+
REPLY_TO_EMAIL=
96+
```
97+
98+
### GitHub OAuth
99+
100+
To authenticate with GitHub, you will need to set up a GitHub OAuth app. It needs a callback URL `https://<your_webapp_domain>/auth/github/callback` and you will have to set the following env vars:
101+
102+
```bash
103+
AUTH_GITHUB_CLIENT_ID=<your_client_id>
104+
AUTH_GITHUB_CLIENT_SECRET=<your_client_secret>
105+
```
106+
107+
### Restricting access
108+
109+
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:
110+
111+
```bash
112+
# every email that does not match this regex will be rejected
113+
WHITELISTED_EMAILS="authorized@yahoo\.com|authorized@gmail\.com"
114+
```
115+
116+
This will apply to all auth methods.
117+
118+
## CLI usage
119+
120+
This section highlights some of the CLI commands and options that are useful when self-hosting. Please check the [CLI reference](/cli-introduction) for more in-depth documentation.
121+
122+
### Login
123+
124+
To avoid being redirected to [Trigger.dev Cloud](https://cloud.trigger.dev) when using the CLI, you need to specify the URL of your self-hosted instance with the `--api-url` or `-a` flag. For example:
125+
126+
```bash
127+
npx trigger.dev@v4-beta login -a http://trigger.example.com
128+
```
129+
130+
Once you've logged in, you shouldn't have to specify the URL again with other commands.
131+
132+
#### Profiles
133+
134+
You can specify a profile when logging in. This allows you to easily use the CLI with multiple instances of Trigger.dev. For example:
135+
136+
```bash
137+
npx trigger.dev@v4-beta login -a http://trigger.example.com \
138+
--profile self-hosted
139+
```
140+
141+
Logging in with a new profile will also make it the new default profile.
142+
143+
To use a specific profile, you can use the `--profile` flag with other commands:
144+
145+
```bash
146+
npx trigger.dev@v4-beta dev --profile self-hosted
147+
```
148+
149+
To list all your profiles, use the `list-profiles` command:
150+
151+
```bash
152+
npx trigger.dev@v4-beta list-profiles
153+
```
154+
155+
To remove a profile, use the `logout` command:
156+
157+
```bash
158+
npx trigger.dev@v4-beta logout --profile self-hosted
159+
```
160+
161+
To switch to a different profile, use the `switch` command:
162+
163+
```bash
164+
# To run interactively
165+
npx trigger.dev@v4-beta switch
166+
167+
# To switch to a specific profile
168+
npx trigger.dev@v4-beta switch self-hosted
169+
```
170+
171+
#### Whoami
172+
173+
It can be useful to check you are logged into the correct instance. Running this will also show the API URL:
174+
175+
```bash
176+
npx trigger.dev@v4-beta whoami
177+
```
178+
179+
### CI / GitHub Actions
180+
181+
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
182+
variables to point at your self-hosted instance and authenticate.
183+
184+
For more detailed instructions, see the [GitHub Actions guide](/github-actions).
185+
186+
## Telemetry
187+
188+
By default, the Trigger.dev webapp sends telemetry data to our servers. This data is used to improve the product and is not shared with third parties. If you would like to opt-out of this, you can set the `TRIGGER_TELEMETRY_DISABLED` environment variable on the webapp container. The value doesn't matter, it just can't be empty. For example:
189+
190+
```yaml
191+
services:
192+
webapp:
193+
...
194+
environment:
195+
TRIGGER_TELEMETRY_DISABLED: 1
196+
```

0 commit comments

Comments
 (0)