Skip to content

Commit a73208d

Browse files
committed
some tweaks
1 parent e7ecb03 commit a73208d

File tree

9 files changed

+130
-27
lines changed

9 files changed

+130
-27
lines changed

docs/self-hosting/docker.mdx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,20 @@ cp .env.example .env
8282
3. Start the webapp
8383

8484
```bash
85-
docker compose -f docker-compose.webapp.yml up -d
85+
cd webapp
86+
docker compose up -d
8687
```
8788

8889
4. Optional: Add traefik as a reverse proxy
8990

9091
```bash
91-
docker compose -f docker-compose.webapp.yml -f docker-compose.traefik.yml up -d
92+
docker compose -f ../docker-compose.traefik.yml up -d
9293
```
9394

9495
Configure the webapp as needed using the [environment variables](/self-hosting/env/webapp) and apply the changes:
9596

9697
```bash
97-
docker compose -f docker-compose.webapp.yml up -d
98+
docker compose up -d
9899
```
99100

100101
### Worker
@@ -115,13 +116,14 @@ cp .env.example .env
115116
3. Start the worker
116117

117118
```bash
118-
docker compose -f docker-compose.worker.yml up -d
119+
cd worker
120+
docker compose up -d
119121
```
120122

121123
Configure the supervisor as needed using the [environment variables](/self-hosting/env/supervisor) and apply the changes:
122124

123125
```bash
124-
docker compose -f docker-compose.worker.yml up -d
126+
docker compose up -d
125127
```
126128

127129
Repeat as needed for additional workers.
@@ -131,12 +133,14 @@ Repeat as needed for additional workers.
131133
If you want to run the webapp and worker on the same machine, just replace the `up` command with the following:
132134

133135
```bash
136+
# Run this from the /hosting/docker directory
134137
docker compose -f docker-compose.webapp.yml -f docker-compose.worker.yml up -d
135138
```
136139

137140
And optionally add traefik as a reverse proxy:
138141

139142
```bash
143+
# Run this from the /hosting/docker directory
140144
docker compose -f docker-compose.webapp.yml -f docker-compose.worker.yml -f docker-compose.traefik.yml up -d
141145
```
142146

@@ -218,6 +222,22 @@ WHITELISTED_EMAILS="authorized@yahoo\.com|authorized@gmail\.com"
218222

219223
This will apply to all auth methods.
220224

225+
## Troubleshooting
226+
227+
- **Deployment fails at the push step.** The machine running `deploy` needs registry access:
228+
229+
```bash
230+
docker login -u <username> <registry>
231+
# this should now succeed
232+
npx trigger.dev@v4-beta deploy
233+
```
234+
235+
This needs to match the registry credentials. Defaults for the `localhost:5000` registry are `registry-user` and `very-safe-password`. You should change these.
236+
237+
- **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.
238+
239+
You should check the logs of the webapp container to see the magic link: `docker logs -f trigger-webapp-1`
240+
221241
## CLI usage
222242

223243
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.

hosting/docker/.env.example

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Secrets
2+
# - Do NOT use these defaults in production
3+
# - Generate your own by running `openssl rand -hex 16` for each secret
4+
SESSION_SECRET=2818143646516f6fffd707b36f334bbb
5+
MAGIC_LINK_SECRET=44da78b7bbb0dfe709cf38931d25dcdd
6+
ENCRYPTION_KEY=f686147ab967943ebbe9ed3b496e465a
7+
MANAGED_WORKER_SECRET=447c29678f9eaf289e9c4b70d3dd8a7f
8+
9+
# Trigger image tags
10+
# - You should lock these to a specific version in production
11+
# - For example: SUPERVISOR_IMAGE_TAG=v4-beta.21
12+
SUPERVISOR_IMAGE_TAG=v4-beta
13+
WEBAPP_IMAGE_TAG=v4-beta
14+
15+
# Webapp
16+
APP_ORIGIN=http://localhost:8030
17+
LOGIN_ORIGIN=http://localhost:8030
18+
# WEBAPP_PUBLISH_IP=0.0.0.0
19+
20+
# Object store
21+
# - You need to set these up via the Minio dashboard first: http://localhost:9001
22+
# - See Minio section for login details
23+
# OBJECT_STORE_ACCESS_KEY_ID=
24+
# OBJECT_STORE_SECRET_ACCESS_KEY=
25+
26+
# Postgres
27+
# - Do NOT use these defaults in production
28+
# - Especially if you decide to expose the database to the internet
29+
POSTGRES_USER=postgres
30+
POSTGRES_PASSWORD=postgres
31+
POSTGRES_DB=postgres
32+
# POSTGRES_PUBLISH_IP=127.0.0.1
33+
# POSTGRES_IMAGE_TAG=14
34+
35+
# Redis
36+
# REDIS_PUBLISH_IP=127.0.0.1
37+
# REDIS_IMAGE_TAG=7
38+
39+
# ElectricSQL
40+
# ELECTRIC_IMAGE_TAG=
41+
42+
# Clickhouse
43+
# CLICKHOUSE_IMAGE_TAG=latest
44+
# CLICKHOUSE_PUBLISH_IP=127.0.0.1
45+
46+
# Registry
47+
# REGISTRY_IMAGE_TAG=2
48+
# REGISTRY_PUBLISH_IP=127.0.0.1
49+
50+
# Minio
51+
# MINIO_IMAGE_TAG=latest
52+
# MINIO_PUBLISH_IP=127.0.0.1
53+
# MINIO_ROOT_USER=admin
54+
# MINIO_ROOT_PASSWORD=very-safe-password
55+
56+
# Docker Registry
57+
# DEPLOY_REGISTRY_HOST=localhost:5000
58+
# DOCKER_REGISTRY_URL=
59+
# DOCKER_REGISTRY_USERNAME=
60+
# DOCKER_REGISTRY_PASSWORD=
61+
62+
# Docker Socket Proxy
63+
# DOCKER_PROXY_IMAGE_TAG=latest
64+
65+
# Traefik
66+
# TRAEFIK_ENTRYPOINT=websecure
67+
# TRAEFIK_IMAGE_TAG=latest
68+
# RESTART_POLICY=
69+
# TRAEFIK_HTTP_PUBLISH_IP=0.0.0.0
70+
# TRAEFIK_HTTPS_PUBLISH_IP=0.0.0.0
71+
# TRAEFIK_DASHBOARD_PUBLISH_IP=127.0.0.1

hosting/docker/docker-compose.traefik.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ services:
3535
image: traefik:${TRAEFIK_IMAGE_TAG:-v3.4}
3636
restart: ${RESTART_POLICY:-unless-stopped}
3737
ports:
38-
- "80:80"
39-
- "443:443"
40-
- "8080:8080" # Traefik dashboard
38+
- "${TRAEFIK_HTTP_PUBLISH_IP:-0.0.0.0}:80:80"
39+
- "${TRAEFIK_HTTPS_PUBLISH_IP:-0.0.0.0}:443:443"
40+
- "${TRAEFIK_DASHBOARD_PUBLISH_IP:-127.0.0.1}:8080:8080" # dashboard
4141
networks:
4242
- traefik
4343
command:

hosting/docker/webapp/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.env

hosting/docker/webapp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# preserve the .env symlink
2+
!.env

hosting/docker/docker-compose.webapp.yml renamed to hosting/docker/webapp/docker-compose.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: trigger
22

33
services:
44
webapp:
5-
image: ghcr.io/triggerdotdev/trigger.dev:${TRIGGER_IMAGE_TAG:-main}
5+
image: ghcr.io/triggerdotdev/trigger.dev:${WEBAPP_IMAGE_TAG:-v4-beta}
66
restart: ${RESTART_POLICY:-unless-stopped}
77
ports:
88
- ${WEBAPP_PUBLISH_IP:-0.0.0.0}:8030:3000
@@ -14,7 +14,9 @@ services:
1414
- supervisor
1515
volumes:
1616
- shared:/home/node/shared
17+
# Only needed for bootstrap
1718
user: root
19+
# Only needed for bootstrap
1820
command: sh -c "chown -R node:node /home/node/shared && exec ./scripts/entrypoint.sh"
1921
healthcheck:
2022
test: ["CMD", "node", "-e", "http.get('http://localhost:3000/healthcheck', res => process.exit(res.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"]
@@ -23,7 +25,8 @@ services:
2325
retries: 5
2426
start_period: 10s
2527
environment:
26-
APP_ORIGIN: http://localhost:8030
28+
APP_ORIGIN: ${APP_ORIGIN:-http://localhost:8030}
29+
LOGIN_ORIGIN: ${LOGIN_ORIGIN:-http://localhost:8030}
2730
ELECTRIC_ORIGIN: http://electric:3000
2831
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/main?schema=public&sslmode=disable
2932
DIRECT_URL: postgresql://postgres:postgres@postgres:5432/main?schema=public&sslmode=disable
@@ -36,14 +39,16 @@ services:
3639
REDIS_TLS_DISABLED: true
3740
APP_LOG_LEVEL: info
3841
DEV_OTEL_EXPORTER_OTLP_ENDPOINT: http://localhost:8030/otel
39-
TRIGGER_BOOTSTRAP_ENABLED: 1
40-
TRIGGER_BOOTSTRAP_WORKER_GROUP_NAME: bootstrap-3
41-
TRIGGER_BOOTSTRAP_WORKER_TOKEN_PATH: /home/node/shared/worker_token
42-
DEPLOY_REGISTRY_HOST: localhost:5000
42+
DEPLOY_REGISTRY_HOST: ${DEPLOY_REGISTRY_HOST:-localhost:5000}
4343
OBJECT_STORE_BASE_URL: http://minio:9000
4444
OBJECT_STORE_ACCESS_KEY_ID: ${OBJECT_STORE_ACCESS_KEY_ID}
4545
OBJECT_STORE_SECRET_ACCESS_KEY: ${OBJECT_STORE_SECRET_ACCESS_KEY}
4646
GRACEFUL_SHUTDOWN_TIMEOUT: 1000
47+
# Bootstrap - this will automatically set up a worker group for you
48+
# This will NOT work for split deployments
49+
TRIGGER_BOOTSTRAP_ENABLED: 1
50+
TRIGGER_BOOTSTRAP_WORKER_GROUP_NAME: bootstrap
51+
TRIGGER_BOOTSTRAP_WORKER_TOKEN_PATH: /home/node/shared/worker_token
4752
# Limits
4853
# TASK_PAYLOAD_OFFLOAD_THRESHOLD: 524288 # 512KB
4954
# TASK_PAYLOAD_MAXIMUM_SIZE: 3145728 # 3MB
@@ -65,9 +70,9 @@ services:
6570
- -c
6671
- wal_level=logical
6772
environment:
68-
POSTGRES_USER: postgres
69-
POSTGRES_PASSWORD: postgres
70-
POSTGRES_DB: postgres
73+
POSTGRES_USER: ${POSTGRES_USER:-postgres}
74+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
75+
POSTGRES_DB: ${POSTGRES_DB:-postgres}
7176
healthcheck:
7277
test: ["CMD", "pg_isready", "-U", "postgres"]
7378
interval: 10s
@@ -119,7 +124,7 @@ services:
119124
CLICKHOUSE_ADMIN_PASSWORD: password
120125
volumes:
121126
- clickhouse:/bitnami/clickhouse
122-
- ./clickhouse/override.xml:/bitnami/clickhouse/etc/config.d/override.xml:ro
127+
- ../clickhouse/override.xml:/bitnami/clickhouse/etc/config.d/override.xml:ro
123128
networks:
124129
- webapp
125130
healthcheck:
@@ -138,18 +143,17 @@ services:
138143
- webapp
139144
volumes:
140145
# registry-user:very-secure-indeed
141-
- ./registry/auth.htpasswd:/auth/htpasswd:ro
146+
- ../registry/auth.htpasswd:/auth/htpasswd:ro
142147
environment:
143148
REGISTRY_AUTH: htpasswd
144149
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
145150
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
146-
# This won't work with auth enabled
147-
# healthcheck:
148-
# test: ["CMD", "wget", "--spider", "-q", "http://localhost:5000/v2/"]
149-
# interval: 10s
150-
# timeout: 5s
151-
# retries: 5
152-
# start_period: 10s
151+
healthcheck:
152+
test: ["CMD", "wget", "--spider", "-q", "http://localhost:5000/"]
153+
interval: 10s
154+
timeout: 5s
155+
retries: 5
156+
start_period: 10s
153157

154158
minio:
155159
image: minio/minio:${MINIO_IMAGE_TAG:-latest}

hosting/docker/worker/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.env

hosting/docker/worker/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# preserve the .env symlink
2+
!.env

hosting/docker/docker-compose.worker.yml renamed to hosting/docker/worker/docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: trigger
22

33
services:
44
supervisor:
5-
image: ghcr.io/triggerdotdev/supervisor:${TRIGGER_IMAGE_TAG:-main}
5+
image: ghcr.io/triggerdotdev/supervisor:${SUPERVISOR_IMAGE_TAG:-v4-beta}
66
restart: ${RESTART_POLICY:-unless-stopped}
77
depends_on:
88
- docker-proxy
@@ -11,7 +11,9 @@ services:
1111
- docker-proxy
1212
volumes:
1313
- shared:/home/node/shared
14+
# Only needed for bootstrap
1415
user: root
16+
# Only needed for bootstrap
1517
command: sh -c "chown -R node:node /home/node/shared && exec /usr/bin/dumb-init -- pnpm run --filter supervisor start"
1618
environment:
1719
# This needs to match the token of the worker group you want to connect to

0 commit comments

Comments
 (0)