fix(create-voltagent-app): generate Dockerfile dependency layers for the selected package manager

D4
4d ago
+111-10

Describe the changes

create-voltagent-app generated one Dockerfile for every project, with unconditional COPY yarn.lock* ./ and COPY pnpm-lock.yaml* ./ instructions in both stages. Docker validates each COPY source against the build context before any RUN fallback executes, so an npm project (only package.json + package-lock.json) failed its first docker build at the yarn.lock copy and the npm ci path was never reached. Bun projects produce neither file and failed the same way.

The Dockerfile is now rendered from ProjectOptions.packageManager:

  • npm: copies package*.json (which matches package-lock.json too) and runs npm ci / npm ci --omit=dev.
  • yarn: copies yarn.lock* and runs yarn install --frozen-lockfile / --production.
  • pnpm: copies pnpm-lock.yaml* and runs pnpm install --frozen-lockfile / --prod (after npm install -g pnpm).
  • bun: copies bun.lock* and runs bun install --frozen-lockfile / --production (after npm install -g bun).

The lockfile copy line is emitted only when the selected package manager has one, so npm projects no longer get an empty COPY failure. The install commands are the same ones the previous runtime fallback dispatched — they just become reachable now.

Validation

  • New tests in packages/create-voltagent-app/src/__tests__/templates.test.ts (all failed before the change, pass after):
    • npm render: contains RUN npm ci / RUN npm ci --omit=dev, contains no yarn.lock / pnpm-lock.yaml
    • lockfile copy matches the selection (yarn.lock* / pnpm-lock.yaml* / bun.lock*), and no other manager's lockfile leaks in
    • install commands match the selection per stage
    • COPY package*.json ./ kept in both stages
  • npx vitest run src/__tests__/templates.test.ts → 4 passed
  • npx biome check src/utils/templates.ts src/__tests__/templates.test.ts → clean
  • Manually rendered the template for npm: dependency layer reads COPY package*.json ./ → RUN npm ci, no stray lockfile copies.

Fixes #1427


Summary by cubic

Fixes Docker builds failing for npm and bun projects generated by create-voltagent-app.

The Dockerfile template unconditionally copied yarn.lock and pnpm-lock.yaml, which Docker validates before any fallback logic runs. npm projects (which only have package-lock.json) and bun projects (which have neither file) failed at the first COPY. The Dockerfile now renders its lockfile copy and install commands from the package manager selected in the wizard, so each project only references its own files.

  • npm projects copy package*.json and run npm ci / npm ci --omit=dev.
  • Yarn, pnpm, and bun projects copy their own lockfile and use their native install commands.
  • Adds tests covering the rendered Dockerfile per package manager.

Summary by CodeRabbit

  • New Features
    • Dockerfiles generated by the app scaffolder now use install commands and lockfiles that match the selected package manager, including Bun.
    • Generated Dockerfiles copy package manifests in both build stages.

Current revision validation

All 6 Dockerfile template tests pass. Each package manager is checked against exact builder and production commands and excludes foreign lockfiles. Biome passes. Docker image builds were not run.