6c9f1f197e
## Summary
Two papercuts new contributors hit running this repo locally:
1. Fresh clones default to v1 (Redis-only) realtime streams, so Sessions
and `chat.agent` error with `"S2 configuration is missing"`, even though
the `s2` service is already in `docker/docker-compose.yml` and pre-seeds
a `trigger-local` basin. Wire `REALTIME_STREAMS_S2_*` to it in
`.env.example` so the new-contributor flow just works. (Also drop the s2
healthcheck: the image is distroless, so the `wget` check always reports
unhealthy.)
2. Two clones can't both run `pnpm run docker` because ports, project
name, and container names are all hardcoded. Parameterize every host
port as `${VAR:-default}`, drive the project name via
`COMPOSE_PROJECT_NAME` (with a top-level `name:` field as the default),
prefix container names with `${CONTAINER_PREFIX:-}`, and pass
`--env-file .env` so compose reads the same root `.env` the webapp does.
The "Running multiple instances side by side" block in `.env.example`
lists every overridable knob.
Also split the optional services (`electric-shard-1`, `ch-ui`,
`toxiproxy`, `nginx-h2`, `otel-collector`, `prometheus`, `grafana`) into
`docker-compose.extras.yml` behind a new `pnpm run docker:full` script.
The core stack keeps everything the webapp actually needs to boot:
postgres, redis, electric, minio, clickhouse + migrator, s2-lite.
Defaults match every previous hardcoded value, so existing setups keep
working without touching `.env`.
## Test plan
- [x] `pnpm run docker` on a clean clone brings up the core services on
the standard ports under the `triggerdotdev-docker` project name.
- [x] Setting `COMPOSE_PROJECT_NAME=triggerdotdev-docker-alt` + the
`*_HOST_PORT` overrides in `.env` brings up a second stack alongside the
default one with no port or container-name clashes.
- [x] Webapp boots cleanly against the default `.env.example` values;
`/healthcheck` returns 200, no S2 errors.
- [x] s2-lite basin `trigger-local` accepts an append + read via the
same REST endpoints the webapp uses.
- [x] `pnpm run docker:full` brings up the optional services alongside
the core ones in the same project.
3.0 KiB
3.0 KiB
Guidance for Coding Agents
This repository is a pnpm monorepo managed with Turbo. It contains multiple apps and packages that make up the Trigger.dev platform and SDK.
Repository layout
apps/webapp– Remix application that serves as the main API and dashboard.apps/supervisor– Node application for executing built tasks.packages/*– Published packages such as@trigger.dev/sdk, the CLI (trigger.dev), and shared libraries.internal-packages/*– Internal-only packages used by the webapp and other apps.references/*– Example projects for manual testing and development of new features.ai/references– Contains additional documentation including an overview (repo.md) and testing guidelines (tests.md).
See ai/references/repo.md for a more complete explanation of the workspaces.
Development setup
- Install dependencies with
pnpm i(pnpm10.33.2and Node.js20.20.0are required). - Copy
.env.exampleto.envand generate a random 16 byte hex string forENCRYPTION_KEY(openssl rand -hex 16). Update other secrets if needed. - Start the local services with Docker:
Add
pnpm run docker:full(pnpm run docker:full) for the optional observability + chaos tooling. Seedocker/docker-compose.extras.yml. - Run database migrations:
pnpm run db:migrate - Build the webapp, CLI and SDK packages:
pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk - Launch the development server:
The webapp runs on http://localhost:3030.
pnpm run dev --filter webapp
For full setup instructions see CONTRIBUTING.md.
Running tests
- Unit tests use vitest. Run all tests:
pnpm run test - Run tests for a specific workspace (example for
webapp):pnpm run test --filter webapp - Prefer running a single test file from within its directory:
If packages in that workspace need to be built first, run
cd apps/webapp pnpm run test ./src/components/Button.test.tspnpm run build --filter webapp.
Refer to ai/references/tests.md for details on writing tests. Tests should avoid mocks or stubs and use the helpers from @internal/testcontainers when Redis or Postgres are needed.
Coding style
- Formatting is enforced using Prettier. Run
pnpm run formatbefore committing. - Follow the existing project conventions. Test files live beside the files under test and use descriptive
describeanditblocks. - Do not commit directly to the
mainbranch. All changes should be made in a separate branch and go through a pull request.
Additional docs
- The root
README.mddescribes Trigger.dev and links to documentation. - The
docsworkspace contains our documentation site, which can be run locally with:pnpm run dev --filter docs references/README.mdexplains how to create new reference projects for manual testing.