From a11b48475ec0ce743398c03e7743eb52da953e54 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:33:20 +0100 Subject: [PATCH 1/9] shallow clone --- docs/self-hosting/docker.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/self-hosting/docker.mdx b/docs/self-hosting/docker.mdx index e6ac5758fd..85de9ebfe7 100644 --- a/docs/self-hosting/docker.mdx +++ b/docs/self-hosting/docker.mdx @@ -70,7 +70,7 @@ You may need to spin up multiple workers to handle peak concurrency. The good ne 1. Clone the repository ```bash -git clone https://github.com/triggerdotdev/trigger.dev +git clone --depth=1 https://github.com/triggerdotdev/trigger.dev cd trigger.dev/hosting/docker ``` @@ -116,7 +116,7 @@ docker compose -f docker-compose.yml -f ../docker-compose.traefik.yml up -d 1. Clone the repository ```bash -git clone https://github.com/triggerdotdev/trigger.dev +git clone --depth=1 https://github.com/triggerdotdev/trigger.dev cd trigger.dev/hosting/docker ``` From 18a2fd2d502b389f2aca0f51d99d797527396f32 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:35:11 +0100 Subject: [PATCH 2/9] fix image tag locking example --- hosting/docker/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/docker/.env.example b/hosting/docker/.env.example index 946bd3d311..6e8c1cb10d 100644 --- a/hosting/docker/.env.example +++ b/hosting/docker/.env.example @@ -29,7 +29,7 @@ DIRECT_URL=postgresql://postgres:unsafe-postgres-pw@postgres:5432/main?schema=pu # Trigger image tag # - This is the version of the webapp and worker images to use, they should be locked to a specific version in production -# - For example: TRIGGER_IMAGE_TAG=v4-beta.21 +# - For example: TRIGGER_IMAGE_TAG=v4.0.0-v4-beta.21 TRIGGER_IMAGE_TAG=v4-beta # Webapp From 1ee2781d1ed274160ec27f6d6a06d583c988c6c0 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:38:18 +0100 Subject: [PATCH 3/9] electric should use db url env var --- hosting/docker/webapp/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/docker/webapp/docker-compose.yml b/hosting/docker/webapp/docker-compose.yml index b458f84f44..3ef7f80184 100644 --- a/hosting/docker/webapp/docker-compose.yml +++ b/hosting/docker/webapp/docker-compose.yml @@ -105,7 +105,7 @@ services: networks: - webapp environment: - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/main?schema=public&sslmode=disable + DATABASE_URL: ${DATABASE_URL:-postgresql://postgres:postgres@postgres:5432/main?schema=public&sslmode=disable} ELECTRIC_INSECURE: true ELECTRIC_USAGE_REPORTING: false healthcheck: From b0cd90cd8ef41a872f14c0caddcef270ced40b42 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:47:10 +0100 Subject: [PATCH 4/9] add htpasswd note --- docs/self-hosting/docker.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/self-hosting/docker.mdx b/docs/self-hosting/docker.mdx index 85de9ebfe7..5bbb225f6a 100644 --- a/docs/self-hosting/docker.mdx +++ b/docs/self-hosting/docker.mdx @@ -212,6 +212,8 @@ The default settings for the registry are: 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). +**Note:** This will require modifying the default `.htpasswd` file located at `./hosting/docker/registry/auth.htpasswd` of the repo root. + ### Logging in 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: From 89515e2b0400824ae70f6593a0021d156f44140d Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:01:00 +0100 Subject: [PATCH 5/9] use local driver with log rotation by default --- hosting/docker/.env.example | 7 +++++++ hosting/docker/webapp/docker-compose.yml | 16 +++++++++++++++- hosting/docker/worker/docker-compose.yml | 9 +++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hosting/docker/.env.example b/hosting/docker/.env.example index 6e8c1cb10d..334f163922 100644 --- a/hosting/docker/.env.example +++ b/hosting/docker/.env.example @@ -101,6 +101,13 @@ OBJECT_STORE_SECRET_ACCESS_KEY=very-safe-password # - Applies to all services, adjust as needed # RESTART_POLICY=unless-stopped +# Docker logging +# - See the official docs: https://docs.docker.com/engine/logging/configure/ +# LOGGING_DRIVER=local +# LOGGING_MAX_SIZE=20m +# LOGGING_MAX_FILES=5 +# LOGGING_COMPRESS=true + # Traefik # - Reverse proxy settings only serve as an example and require further configuration # - See the partial overrides in docker-compose.traefik.yml for more details diff --git a/hosting/docker/webapp/docker-compose.yml b/hosting/docker/webapp/docker-compose.yml index 3ef7f80184..16bda65810 100644 --- a/hosting/docker/webapp/docker-compose.yml +++ b/hosting/docker/webapp/docker-compose.yml @@ -1,9 +1,17 @@ name: trigger +x-logging: &logging-config + driver: ${LOGGING_DRIVER:-local} + options: + max-size: ${LOGGING_MAX_SIZE:-20m} + max-file: ${LOGGING_MAX_FILES:-5} + compress: ${LOGGING_COMPRESS:-true} + services: webapp: image: ghcr.io/triggerdotdev/trigger.dev:${TRIGGER_IMAGE_TAG:-v4-beta} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config ports: - ${WEBAPP_PUBLISH_IP:-0.0.0.0}:8030:3000 depends_on: @@ -61,6 +69,7 @@ services: postgres: image: postgres:${POSTGRES_IMAGE_TAG:-14} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config ports: - ${POSTGRES_PUBLISH_IP:-127.0.0.1}:5433:5432 volumes: @@ -84,6 +93,7 @@ services: redis: image: redis:${REDIS_IMAGE_TAG:-7} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config ports: - ${REDIS_PUBLISH_IP:-127.0.0.1}:6389:6379 volumes: @@ -100,6 +110,7 @@ services: electric: image: electricsql/electric:${ELECTRIC_IMAGE_TAG:-1.0.13} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config depends_on: - postgres networks: @@ -118,6 +129,7 @@ services: clickhouse: image: bitnami/clickhouse:${CLICKHOUSE_IMAGE_TAG:-latest} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config ports: - ${CLICKHOUSE_PUBLISH_IP:-127.0.0.1}:9090:9000 environment: @@ -138,6 +150,7 @@ services: registry: image: registry:${REGISTRY_IMAGE_TAG:-2} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config ports: - ${REGISTRY_PUBLISH_IP:-127.0.0.1}:5000:5000 networks: @@ -159,6 +172,7 @@ services: minio: image: minio/minio:${MINIO_IMAGE_TAG:-latest} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config ports: - ${MINIO_PUBLISH_IP:-127.0.0.1}:9000:9000 - ${MINIO_PUBLISH_IP:-127.0.0.1}:9001:9001 @@ -190,4 +204,4 @@ networks: supervisor: name: supervisor webapp: - name: webapp + name: webapp \ No newline at end of file diff --git a/hosting/docker/worker/docker-compose.yml b/hosting/docker/worker/docker-compose.yml index 0ccf8544e9..b6a49d9c52 100644 --- a/hosting/docker/worker/docker-compose.yml +++ b/hosting/docker/worker/docker-compose.yml @@ -1,9 +1,17 @@ name: trigger +x-logging: &logging-config + driver: ${LOGGING_DRIVER:-local} + options: + max-size: ${LOGGING_MAX_SIZE:-20m} + max-file: ${LOGGING_MAX_FILES:-5} + compress: ${LOGGING_COMPRESS:-true} + services: supervisor: image: ghcr.io/triggerdotdev/supervisor:${TRIGGER_IMAGE_TAG:-v4-beta} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config depends_on: - docker-proxy networks: @@ -48,6 +56,7 @@ services: docker-proxy: image: tecnativa/docker-socket-proxy:${DOCKER_PROXY_IMAGE_TAG:-latest} restart: ${RESTART_POLICY:-unless-stopped} + logging: *logging-config volumes: - /var/run/docker.sock:/var/run/docker.sock:ro networks: From ee68a2675e39fdf12cfba7a73dd5238e7f0da023 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:19:45 +0100 Subject: [PATCH 6/9] make worker urls more easily configurable --- hosting/docker/.env.example | 12 ++++++++++-- hosting/docker/worker/docker-compose.yml | 6 ++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hosting/docker/.env.example b/hosting/docker/.env.example index 334f163922..ecc826b783 100644 --- a/hosting/docker/.env.example +++ b/hosting/docker/.env.example @@ -52,17 +52,25 @@ API_ORIGIN=http://localhost:8030 # - 8GB machine: NODE_MAX_OLD_SPACE_SIZE=6400 # NODE_MAX_OLD_SPACE_SIZE=8192 +# Worker +# - These are the settings for the worker and will depend on your setup +# - Any defaults are designed to work out of the box with the combined setup +# Point this at the webapp in prod +# TRIGGER_API_URL=http://webapp:3000 +# Point this at your OTel collector or the webapp in prod +# OTEL_EXPORTER_OTLP_ENDPOINT=http://webapp:3000/otel + # Docker Registry # - When testing locally, the default values should be fine # - When deploying to production, you will have to change these, especially the password and URL -# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker +# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker#registry-setup DOCKER_REGISTRY_URL=localhost:5000 DOCKER_REGISTRY_USERNAME=registry-user DOCKER_REGISTRY_PASSWORD=very-secure-indeed # Object store # - You need to log into the Minio dashboard and create a bucket called "packets" -# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker +# - See the docs for more information: https://trigger.dev/docs/self-hosting/docker#object-storage OBJECT_STORE_ACCESS_KEY_ID=admin OBJECT_STORE_SECRET_ACCESS_KEY=very-safe-password # You will have to uncomment and configure this for production diff --git a/hosting/docker/worker/docker-compose.yml b/hosting/docker/worker/docker-compose.yml index b6a49d9c52..6e9f4db272 100644 --- a/hosting/docker/worker/docker-compose.yml +++ b/hosting/docker/worker/docker-compose.yml @@ -30,10 +30,8 @@ services: # Use the bootstrap token created by the webapp TRIGGER_WORKER_TOKEN: file:///home/node/shared/worker_token MANAGED_WORKER_SECRET: ${MANAGED_WORKER_SECRET} - # Point this at the webapp in prod - TRIGGER_API_URL: http://webapp:3000 - # Point this at the OTel collector or the webapp in prod - OTEL_EXPORTER_OTLP_ENDPOINT: http://webapp:3000/otel + TRIGGER_API_URL: ${TRIGGER_API_URL:-http://webapp:3000} + OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://webapp:3000/otel} TRIGGER_WORKLOAD_API_DOMAIN: supervisor TRIGGER_WORKLOAD_API_PORT_EXTERNAL: 8020 # Optional settings From 0d624d15d51c3275e54797837097ca207ba5af10 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:22:23 +0100 Subject: [PATCH 7/9] configure dev otel endpoint via .env --- hosting/docker/.env.example | 1 + hosting/docker/webapp/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hosting/docker/.env.example b/hosting/docker/.env.example index ecc826b783..46ecc2325e 100644 --- a/hosting/docker/.env.example +++ b/hosting/docker/.env.example @@ -38,6 +38,7 @@ TRIGGER_IMAGE_TAG=v4-beta APP_ORIGIN=http://localhost:8030 LOGIN_ORIGIN=http://localhost:8030 API_ORIGIN=http://localhost:8030 +DEV_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8030/otel # You may need to set this when testing locally or when using the combined setup # API_ORIGIN=http://webapp:3000 diff --git a/hosting/docker/webapp/docker-compose.yml b/hosting/docker/webapp/docker-compose.yml index 16bda65810..86309e8bad 100644 --- a/hosting/docker/webapp/docker-compose.yml +++ b/hosting/docker/webapp/docker-compose.yml @@ -47,7 +47,7 @@ services: REDIS_PORT: 6379 REDIS_TLS_DISABLED: true APP_LOG_LEVEL: info - DEV_OTEL_EXPORTER_OTLP_ENDPOINT: http://localhost:8030/otel + DEV_OTEL_EXPORTER_OTLP_ENDPOINT: ${DEV_OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:8030/otel} DEPLOY_REGISTRY_HOST: ${DOCKER_REGISTRY_URL:-localhost:5000} OBJECT_STORE_BASE_URL: ${OBJECT_STORE_BASE_URL:-http://minio:9000} OBJECT_STORE_ACCESS_KEY_ID: ${OBJECT_STORE_ACCESS_KEY_ID} From a8ffda59ccfddb8f3465df36704e3a6e061afb6a Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:30:06 +0100 Subject: [PATCH 8/9] increase min recommended worker specs --- docs/self-hosting/docker.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/self-hosting/docker.mdx b/docs/self-hosting/docker.mdx index 5bbb225f6a..dee37b8d87 100644 --- a/docs/self-hosting/docker.mdx +++ b/docs/self-hosting/docker.mdx @@ -49,8 +49,8 @@ This machine will host the webapp, postgres, redis, and related services. This machine will host the supervisor and all of the runs. -- 2+ vCPU -- 4+ GB RAM +- 4+ vCPU +- 8+ GB RAM How many workers and resources you need will depend on your workloads and concurrency requirements. From 39bc64016a3f9cb6dbe316f906457337643300d9 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:39:17 +0100 Subject: [PATCH 9/9] move worker url section --- hosting/docker/.env.example | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hosting/docker/.env.example b/hosting/docker/.env.example index 46ecc2325e..ce2b1717e0 100644 --- a/hosting/docker/.env.example +++ b/hosting/docker/.env.example @@ -18,6 +18,11 @@ MANAGED_WORKER_SECRET=447c29678f9eaf289e9c4b70d3dd8a7f # - See the docs for more information: https://trigger.dev/docs/self-hosting/docker # TRIGGER_WORKER_TOKEN= +# Worker URLs +# - In split setups, uncomment and set to the public URL of your webapp +# TRIGGER_API_URL=https://trigger.example.com +# OTEL_EXPORTER_OTLP_ENDPOINT=https://trigger.example.com/otel + # Postgres # - Do NOT use these defaults in production # - Especially if you decide to expose the database to the internet @@ -53,14 +58,6 @@ DEV_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8030/otel # - 8GB machine: NODE_MAX_OLD_SPACE_SIZE=6400 # NODE_MAX_OLD_SPACE_SIZE=8192 -# Worker -# - These are the settings for the worker and will depend on your setup -# - Any defaults are designed to work out of the box with the combined setup -# Point this at the webapp in prod -# TRIGGER_API_URL=http://webapp:3000 -# Point this at your OTel collector or the webapp in prod -# OTEL_EXPORTER_OTLP_ENDPOINT=http://webapp:3000/otel - # Docker Registry # - When testing locally, the default values should be fine # - When deploying to production, you will have to change these, especially the password and URL