Skip to content

Commit f7f8bc2

Browse files
authored
Docker self-hosting improvements (#2177)
* shallow clone * fix image tag locking example * electric should use db url env var * add htpasswd note * use local driver with log rotation by default * make worker urls more easily configurable * configure dev otel endpoint via .env * increase min recommended worker specs * move worker url section
1 parent 5f6fd8e commit f7f8bc2

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

docs/self-hosting/docker.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ This machine will host the webapp, postgres, redis, and related services.
4949

5050
This machine will host the supervisor and all of the runs.
5151

52-
- 2+ vCPU
53-
- 4+ GB RAM
52+
- 4+ vCPU
53+
- 8+ GB RAM
5454

5555
How many workers and resources you need will depend on your workloads and concurrency requirements.
5656

@@ -70,7 +70,7 @@ You may need to spin up multiple workers to handle peak concurrency. The good ne
7070
1. Clone the repository
7171

7272
```bash
73-
git clone https://github.com/triggerdotdev/trigger.dev
73+
git clone --depth=1 https://github.com/triggerdotdev/trigger.dev
7474
cd trigger.dev/hosting/docker
7575
```
7676

@@ -116,7 +116,7 @@ docker compose -f docker-compose.yml -f ../docker-compose.traefik.yml up -d
116116
1. Clone the repository
117117

118118
```bash
119-
git clone https://github.com/triggerdotdev/trigger.dev
119+
git clone --depth=1 https://github.com/triggerdotdev/trigger.dev
120120
cd trigger.dev/hosting/docker
121121
```
122122

@@ -212,6 +212,8 @@ The default settings for the registry are:
212212
213213
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).
214214
215+
**Note:** This will require modifying the default `.htpasswd` file located at `./hosting/docker/registry/auth.htpasswd` of the repo root.
216+
215217
### Logging in
216218
217219
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:

hosting/docker/.env.example

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ MANAGED_WORKER_SECRET=447c29678f9eaf289e9c4b70d3dd8a7f
1818
# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker
1919
# TRIGGER_WORKER_TOKEN=
2020

21+
# Worker URLs
22+
# - In split setups, uncomment and set to the public URL of your webapp
23+
# TRIGGER_API_URL=https://trigger.example.com
24+
# OTEL_EXPORTER_OTLP_ENDPOINT=https://trigger.example.com/otel
25+
2126
# Postgres
2227
# - Do NOT use these defaults in production
2328
# - Especially if you decide to expose the database to the internet
@@ -29,7 +34,7 @@ DIRECT_URL=postgresql://postgres:unsafe-postgres-pw@postgres:5432/main?schema=pu
2934

3035
# Trigger image tag
3136
# - This is the version of the webapp and worker images to use, they should be locked to a specific version in production
32-
# - For example: TRIGGER_IMAGE_TAG=v4-beta.21
37+
# - For example: TRIGGER_IMAGE_TAG=v4.0.0-v4-beta.21
3338
TRIGGER_IMAGE_TAG=v4-beta
3439

3540
# Webapp
@@ -38,6 +43,7 @@ TRIGGER_IMAGE_TAG=v4-beta
3843
APP_ORIGIN=http://localhost:8030
3944
LOGIN_ORIGIN=http://localhost:8030
4045
API_ORIGIN=http://localhost:8030
46+
DEV_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8030/otel
4147
# You may need to set this when testing locally or when using the combined setup
4248
# API_ORIGIN=http://webapp:3000
4349

@@ -55,14 +61,14 @@ API_ORIGIN=http://localhost:8030
5561
# Docker Registry
5662
# - When testing locally, the default values should be fine
5763
# - When deploying to production, you will have to change these, especially the password and URL
58-
# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker
64+
# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker#registry-setup
5965
DOCKER_REGISTRY_URL=localhost:5000
6066
DOCKER_REGISTRY_USERNAME=registry-user
6167
DOCKER_REGISTRY_PASSWORD=very-secure-indeed
6268

6369
# Object store
6470
# - You need to log into the Minio dashboard and create a bucket called "packets"
65-
# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker
71+
# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker#object-storage
6672
OBJECT_STORE_ACCESS_KEY_ID=admin
6773
OBJECT_STORE_SECRET_ACCESS_KEY=very-safe-password
6874
# You will have to uncomment and configure this for production
@@ -101,6 +107,13 @@ OBJECT_STORE_SECRET_ACCESS_KEY=very-safe-password
101107
# - Applies to all services, adjust as needed
102108
# RESTART_POLICY=unless-stopped
103109

110+
# Docker logging
111+
# - See the official docs: https://docs.docker.com/engine/logging/configure/
112+
# LOGGING_DRIVER=local
113+
# LOGGING_MAX_SIZE=20m
114+
# LOGGING_MAX_FILES=5
115+
# LOGGING_COMPRESS=true
116+
104117
# Traefik
105118
# - Reverse proxy settings only serve as an example and require further configuration
106119
# - See the partial overrides in docker-compose.traefik.yml for more details

hosting/docker/webapp/docker-compose.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
name: trigger
22

3+
x-logging: &logging-config
4+
driver: ${LOGGING_DRIVER:-local}
5+
options:
6+
max-size: ${LOGGING_MAX_SIZE:-20m}
7+
max-file: ${LOGGING_MAX_FILES:-5}
8+
compress: ${LOGGING_COMPRESS:-true}
9+
310
services:
411
webapp:
512
image: ghcr.io/triggerdotdev/trigger.dev:${TRIGGER_IMAGE_TAG:-v4-beta}
613
restart: ${RESTART_POLICY:-unless-stopped}
14+
logging: *logging-config
715
ports:
816
- ${WEBAPP_PUBLISH_IP:-0.0.0.0}:8030:3000
917
depends_on:
@@ -39,7 +47,7 @@ services:
3947
REDIS_PORT: 6379
4048
REDIS_TLS_DISABLED: true
4149
APP_LOG_LEVEL: info
42-
DEV_OTEL_EXPORTER_OTLP_ENDPOINT: http://localhost:8030/otel
50+
DEV_OTEL_EXPORTER_OTLP_ENDPOINT: ${DEV_OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:8030/otel}
4351
DEPLOY_REGISTRY_HOST: ${DOCKER_REGISTRY_URL:-localhost:5000}
4452
OBJECT_STORE_BASE_URL: ${OBJECT_STORE_BASE_URL:-http://minio:9000}
4553
OBJECT_STORE_ACCESS_KEY_ID: ${OBJECT_STORE_ACCESS_KEY_ID}
@@ -61,6 +69,7 @@ services:
6169
postgres:
6270
image: postgres:${POSTGRES_IMAGE_TAG:-14}
6371
restart: ${RESTART_POLICY:-unless-stopped}
72+
logging: *logging-config
6473
ports:
6574
- ${POSTGRES_PUBLISH_IP:-127.0.0.1}:5433:5432
6675
volumes:
@@ -84,6 +93,7 @@ services:
8493
redis:
8594
image: redis:${REDIS_IMAGE_TAG:-7}
8695
restart: ${RESTART_POLICY:-unless-stopped}
96+
logging: *logging-config
8797
ports:
8898
- ${REDIS_PUBLISH_IP:-127.0.0.1}:6389:6379
8999
volumes:
@@ -100,12 +110,13 @@ services:
100110
electric:
101111
image: electricsql/electric:${ELECTRIC_IMAGE_TAG:-1.0.13}
102112
restart: ${RESTART_POLICY:-unless-stopped}
113+
logging: *logging-config
103114
depends_on:
104115
- postgres
105116
networks:
106117
- webapp
107118
environment:
108-
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/main?schema=public&sslmode=disable
119+
DATABASE_URL: ${DATABASE_URL:-postgresql://postgres:postgres@postgres:5432/main?schema=public&sslmode=disable}
109120
ELECTRIC_INSECURE: true
110121
ELECTRIC_USAGE_REPORTING: false
111122
healthcheck:
@@ -118,6 +129,7 @@ services:
118129
clickhouse:
119130
image: bitnami/clickhouse:${CLICKHOUSE_IMAGE_TAG:-latest}
120131
restart: ${RESTART_POLICY:-unless-stopped}
132+
logging: *logging-config
121133
ports:
122134
- ${CLICKHOUSE_PUBLISH_IP:-127.0.0.1}:9090:9000
123135
environment:
@@ -138,6 +150,7 @@ services:
138150
registry:
139151
image: registry:${REGISTRY_IMAGE_TAG:-2}
140152
restart: ${RESTART_POLICY:-unless-stopped}
153+
logging: *logging-config
141154
ports:
142155
- ${REGISTRY_PUBLISH_IP:-127.0.0.1}:5000:5000
143156
networks:
@@ -159,6 +172,7 @@ services:
159172
minio:
160173
image: minio/minio:${MINIO_IMAGE_TAG:-latest}
161174
restart: ${RESTART_POLICY:-unless-stopped}
175+
logging: *logging-config
162176
ports:
163177
- ${MINIO_PUBLISH_IP:-127.0.0.1}:9000:9000
164178
- ${MINIO_PUBLISH_IP:-127.0.0.1}:9001:9001
@@ -190,4 +204,4 @@ networks:
190204
supervisor:
191205
name: supervisor
192206
webapp:
193-
name: webapp
207+
name: webapp

hosting/docker/worker/docker-compose.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
name: trigger
22

3+
x-logging: &logging-config
4+
driver: ${LOGGING_DRIVER:-local}
5+
options:
6+
max-size: ${LOGGING_MAX_SIZE:-20m}
7+
max-file: ${LOGGING_MAX_FILES:-5}
8+
compress: ${LOGGING_COMPRESS:-true}
9+
310
services:
411
supervisor:
512
image: ghcr.io/triggerdotdev/supervisor:${TRIGGER_IMAGE_TAG:-v4-beta}
613
restart: ${RESTART_POLICY:-unless-stopped}
14+
logging: *logging-config
715
depends_on:
816
- docker-proxy
917
networks:
@@ -22,10 +30,8 @@ services:
2230
# Use the bootstrap token created by the webapp
2331
TRIGGER_WORKER_TOKEN: file:///home/node/shared/worker_token
2432
MANAGED_WORKER_SECRET: ${MANAGED_WORKER_SECRET}
25-
# Point this at the webapp in prod
26-
TRIGGER_API_URL: http://webapp:3000
27-
# Point this at the OTel collector or the webapp in prod
28-
OTEL_EXPORTER_OTLP_ENDPOINT: http://webapp:3000/otel
33+
TRIGGER_API_URL: ${TRIGGER_API_URL:-http://webapp:3000}
34+
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://webapp:3000/otel}
2935
TRIGGER_WORKLOAD_API_DOMAIN: supervisor
3036
TRIGGER_WORKLOAD_API_PORT_EXTERNAL: 8020
3137
# Optional settings
@@ -48,6 +54,7 @@ services:
4854
docker-proxy:
4955
image: tecnativa/docker-socket-proxy:${DOCKER_PROXY_IMAGE_TAG:-latest}
5056
restart: ${RESTART_POLICY:-unless-stopped}
57+
logging: *logging-config
5158
volumes:
5259
- /var/run/docker.sock:/var/run/docker.sock:ro
5360
networks:

0 commit comments

Comments
 (0)