Generated Dockerfile fails on npm projects because it requires Yarn and pnpm lockfiles
Describe the bug
create-voltagent-app includes a Dockerfile in every new project. Its dependency layers contain separate COPY yarn.lock* ./ and COPY pnpm-lock.yaml* ./ instructions in both build stages. Docker requires each COPY source to match a file in the build context. An npm project normally has package.json and package-lock.json, but neither of those other lockfiles, so its first Docker build stops at the yarn.lock* copy. The later RUN block already has an npm fallback, but Docker never reaches it.
The same Dockerfile is generated regardless of the package manager selected in the project wizard. That makes this particularly surprising for someone who chose npm and has a valid package-lock.json: the generated app can install and run locally, but the generated deployment path is unusable without editing the Dockerfile.
Steps To Reproduce
- Create a new project with
create-voltagent-appand select npm when asked for a package manager. - Install dependencies if the wizard has not already done so. Confirm that the project contains
package.jsonandpackage-lock.json, and does not containyarn.lockorpnpm-lock.yaml. - From the generated project directory, run
docker build -t voltagent-npm-repro .. - Docker stops while resolving
COPY yarn.lock* ./in the builder stage because the source file does not exist. The laternpm cipath is never reached.
This also affects other package-manager choices when one of the lockfiles listed in those unconditional COPY instructions is absent. In particular, a Bun project does not produce either file.
Expected behavior
The Dockerfile generated for an npm project should copy package.json and package-lock.json, then run npm ci in the builder stage and npm ci --omit=dev in the runtime stage. It should not require lockfiles from package managers the user did not select. Projects created with Yarn, pnpm, or Bun should likewise use their own lockfile and install command.
Packages
create-voltagent-app0.2.19 (the template inpackages/create-voltagent-app/templates/base/Dockerfile.template)
Additional Context
The dependency-install command in the current template checks for lockfile presence at runtime, but Docker validates COPY sources before executing that command. An optional-looking wildcard such as yarn.lock* is not optional to Docker: it still fails when no matching file is present. The template repeats these instructions in the production stage, so changing only the builder stage would leave the same failure later in the build.
The scaffold already knows the selected package manager through ProjectOptions.packageManager. Using that selection when rendering the Dockerfile would let each stage copy only the lockfile it needs, while keeping the dependency layers ahead of the source copy for Docker layer caching.
Source: VoltAgent/voltagent