Skip to content

perf(templates): prune Docker builds and ship production-only runtimes - #1307

Open
AmanVarshney01 wants to merge 1 commit into
mainfrom
feat/docker-turbo-prune
Open

AmanVarshney01 wants to merge 1 commit into
mainfrom
feat/docker-turbo-prune

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Smaller Docker images and faster rebuilds for generated apps.

  • turbo prune <app> --docker in every Dockerfile: the build installs only the target app's workspace packages from the pruned manifests with a frozen lockfile (bun install --frozen-lockfile / pnpm install --frozen-lockfile / npm ci), then copies sources. Source edits no longer invalidate the dependency install layer. Works without the Turborepo add-on (no turbo.json needed); it does need a lockfile.
  • Production-only runtimes: a separate --prod --ignore-scripts install for runtimes that import node_modules (servers, TanStack Start, React Router, SvelteKit, Astro).
  • Varlock-only runtimes for self-contained bundles (Next standalone, Nuxt, Solid): the image gets just the Varlock CLI (about 6.6 MB) at the version the lockfile resolved, plus the build output.
  • Prisma client is generated inside the image. It's gitignored, so images previously only worked if the host had run db:generate.
  • @tanstack/react-query-devtools moved to dependencies: the React Router SSR bundle imports it at runtime (found when the runtime stopped shipping dev dependencies).
  • Shared Handlebars partials (dockerPrune, dockerInstall, dockerProdInstall, dockerVarlockCli, dockerPrismaGenerate) replace the install block that was copied into 9 Dockerfiles.
  • Docker guide and generated README say to install dependencies once before the first build.

Image sizes (local, linux/arm64)

App Before After
Next (self, SQLite) 1635 MB 497 MB
Next web + Fastify (pnpm, Mongo) 1318 / 1263 MB 439 / 908 MB
Nuxt (self) 1137 MB 426 MB
Solid (self, Prisma) 1169 MB 420 MB
SvelteKit web + Elysia (bun) 1594 / 853 MB 758 / 651 MB
SvelteKit (Prisma, Postgres) 1319 MB 965 MB
TanStack Start (pnpm, Postgres) 1034 MB 883 MB
TanStack Start web + Fastify 1165 / 1160 MB 927 / 590 MB
React Router web + Hono (npm, Prisma MySQL) 1255 / 1265 MB 1094 / 861 MB
Astro (self) 1203 MB 862 MB
TanStack Router (nginx) web + Express (Mongo) 96 / 951 MB 96 / 431 MB

Verification

  • 12-app Docker matrix (the 11 apps above plus Nuxt with npm and Postgres; bun/pnpm/npm; Postgres/MySQL/Mongo/SQLite; Drizzle/Prisma/Mongoose; one app without the Turborepo add-on): every app passed docker compose up --build --wait, then sign-up, sign-in and get-session. All runtimes run as node/bun.
  • End-to-end on the final commit, all 12 apps regenerated with the todo example, each running in its Docker image: auth (sign-up, sign-in, get-session); oRPC todo create/list/toggle/delete; privateData returns the user with a session and 401 without one; headless browser adds a todo on /todos, it is still there after reload, and the signed-in /dashboard shows the user. 96/96 checks pass, no page errors.
  • Rebuild after a source-only edit: the install and Varlock CLI layers are CACHED; only the source copy and build re-run.
  • bun run check clean; apps/cli test:ci 112 pass.

Not covered

  • Images still include the Node/Bun base (around 380 MB). Server images still ship full production node_modules because tsdown keeps third-party deps external.
  • TanStack Router's nginx image still runs as root.

…tion-only runtimes

- Each Dockerfile prunes the workspace to its app with turbo prune --docker,
  installs from the pruned manifests with a frozen lockfile, then copies sources,
  so source edits no longer invalidate the dependency install layer
- Generate the Prisma client inside the image instead of relying on the host
- Runtime images get a production-only install; Next standalone, Nuxt and
  Solid (self-contained bundles) get only the Varlock CLI
- Move @tanstack/react-query-devtools to dependencies: React Router SSR
  imports it at runtime
- Document the lockfile requirement in the Docker guide and generated README
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
create-better-t-stack-web Ready Ready Preview Nov 14, 2026 12:06pm UTC

Request Review

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T12:06:19.353665Z
We couldn’t complete this review. Comment @codex review to try again.
233e333 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Docker image templates now prune workspaces before installing and building. They use shared package-manager steps and define production dependency and runtime stages for server and web applications. The Docker guide and generated deployment instructions describe the updated flow.

Changes

Docker Image Generation

Layer / File(s) Summary
Shared Docker build steps and guidance
packages/template-generator/src/core/template-processor.ts, packages/template-generator/src/processors/api-deps.ts, apps/web/content/docs/guides/docker.mdx, packages/template-generator/src/processors/readme-generator.ts
Shared partials handle workspace pruning, frozen and production installs, Varlock CLI installation, and Prisma generation. React projects place React Query Devtools in production dependencies. The Docker guide and generated Compose instructions describe the updated process.
Server build and runtime stages
packages/template-generator/templates/deploy/docker/server/Dockerfile.hbs
The server Dockerfile builds from pruned workspace output, installs production dependencies in a separate stage, and copies those dependencies and the server distribution into the runner.
Web framework build and runtime stages
packages/template-generator/templates/deploy/docker/web/*/Dockerfile.hbs, packages/template-generator/templates/deploy/docker/web/react/*/Dockerfile.hbs
Web Dockerfiles build from pruned workspace output and use shared install steps. Runtime stages copy framework build output and dependencies; Prisma generation runs where configured.
Merge Risk: Minimal · up to 233e3

This change prunes the monorepo before installing and ships production-only runtimes in generated Docker images. No concrete build or runtime failure was found in the reviewed templates, and the author reports a passing multi-app Docker matrix. It looks safe to merge with normal checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title uses the conventional commit form and names the main change: Docker builds now prune the monorepo to the target app, and runtime images ship production-only dependencies. The raw summary and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title uses the conventional commit form and names the main change: Docker builds now prune the monorepo to the target app, and runtime images ship production-only dependencies. The raw summary and PR objectives both describe these changes, including turbo prune, frozen lockfile installs, and production-only runtime installs. The title is specific and accurate, so it passes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d6457db7-8ca8-43a1-974a-cc4b69c72c39
Commits

Reviewing files that changed from the base of the PR and between 9710754 and 233e333.

Files ignored due to path filters: 1

  • packages/template-generator/src/templates.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 13

  • apps/web/content/docs/guides/docker.mdx
  • packages/template-generator/src/core/template-processor.ts
  • packages/template-generator/src/processors/api-deps.ts
  • packages/template-generator/src/processors/readme-generator.ts
  • packages/template-generator/templates/deploy/docker/server/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/astro/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/nuxt/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/next/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/react-router/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/tanstack-router/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/tanstack-start/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/solid/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/svelte/Dockerfile.hbs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

This branch was successfully deployed

1 active deployment
Preview — 233e333f Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant