nest-monorepo deployment
Images
Section titled “Images”Every image is built from the monorepo root, because each needs
packages/db as well as its app:
docker build -f apps/api/Dockerfile -t shop-api .docker build -f apps/api/Dockerfile --target migrate -t shop-api-migrate .docker build -f apps/worker/Dockerfile -t shop-worker .Each Dockerfile runs turbo prune <app> --docker first: the install layer is
built from that app’s manifests and a pruned lockfile, so it is reused until a
dependency the app actually uses changes. The build stage runs
turbo run build --filter=<app>, which builds @scope/db first, and the
runtime stage keeps production dependencies only.
| Image | Runs | Port |
|---|---|---|
shop-api |
node dist/src/main in apps/api |
5000 |
shop-api-migrate |
prisma migrate deploy against $DATABASE_URL, then exits |
none |
shop-worker |
pm2-runtime (or node, without worker-pm2) in apps/worker |
none |
Deploying
Section titled “Deploying”- Run
shop-api-migrate:<tag>once, with the productionDATABASE_URL. - Start
shop-api:<tag>andshop-worker:<tag>.
Deploy every app on the same tag. They share one Prisma client, so an API and a worker from different commits can disagree about the schema.
Everything else, the API’s variables and health checks, the worker’s process model and Chromium, is as in nest-api and node-worker.
.forgejo/workflows/ at the root:
| Workflow | Runs on | Does |
|---|---|---|
ci.yml |
every branch except main and development |
turbo run lint typecheck test build |
test-e2e.yml |
pull requests into development |
the API’s e2e suite against service containers |
build-and-push.yml |
main, manual runs |
builds every image and pushes them under one shared tag |