Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Prisma 4.x panics when running prisma generate with Bun in Docker deploy stage: RuntimeError: panicked at 'index out of bounds: the len is 0 but the index is 34'.

Changes

Dockerfile (deploy stage)

  • Remove RUN bun run prisma generate
  • Copy pre-generated client from build stage:
    COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
    COPY --from=build /app/node_modules/@prisma/client ./node_modules/@prisma/client

prisma/schema.prisma

  • Add Debian binary target for Docker compatibility:
    binaryTargets = ["native", "debian-openssl-3.0.x"]

Client still generates once in build stage (where it works), deploy stage reuses it.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint.prisma.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/.npm/_npx/2778af9cee32ff87/node_modules/prisma/build/child {"product":"prisma","version":"7.1.0","cli_install_type":"local","information":"","local_timestamp":"2025-12-16T08:54:17Z","project_hash":"050028f6","cli_path":"/home/REDACTED/.npm/_npx/2778af9cee32ff87/node_modules/.bin/prisma","cli_path_hash":"5a8877e8"," (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Problem

The Docker build is failing in the deploy stage when running prisma generate with the error:

Error: RuntimeError: panicked at 'index out of bounds: the len is 0 but the index is 34', psl/parser-database/src/walkers/scalar_field.rs:103:10

This is a known Prisma 4.x compatibility issue with Bun in Docker environments.

Required Changes

1. Update Dockerfile

Remove the RUN bun run prisma generate from the deploy stage and instead copy the pre-generated Prisma client from the build stage.

Replace lines 53-54:

# Generate Prisma client in production environment
RUN bun run prisma generate

With:

# Copy the generated Prisma client from the build stage instead of regenerating
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=build /app/node_modules/@prisma/client ./node_modules/@prisma/client

2. Update prisma/schema.prisma

Update the binaryTargets to explicitly include the Debian target for the Docker image.

Change line 3 from:

binaryTargets = ["native"]

To:

binaryTargets = ["native", "debian-openssl-3.0.x"]

Expected Result

After these changes, the Docker build should complete successfully without the Prisma generate error in the deploy stage.

This pull request was created as a result of the following prompt from Copilot chat.

Problem

The Docker build is failing in the deploy stage when running prisma generate with the error:

Error: RuntimeError: panicked at 'index out of bounds: the len is 0 but the index is 34', psl/parser-database/src/walkers/scalar_field.rs:103:10

This is a known Prisma 4.x compatibility issue with Bun in Docker environments.

Required Changes

1. Update Dockerfile

Remove the RUN bun run prisma generate from the deploy stage and instead copy the pre-generated Prisma client from the build stage.

Replace lines 53-54:

# Generate Prisma client in production environment
RUN bun run prisma generate

With:

# Copy the generated Prisma client from the build stage instead of regenerating
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=build /app/node_modules/@prisma/client ./node_modules/@prisma/client

2. Update prisma/schema.prisma

Update the binaryTargets to explicitly include the Debian target for the Docker image.

Change line 3 from:

binaryTargets = ["native"]

To:

binaryTargets = ["native", "debian-openssl-3.0.x"]

Expected Result

After these changes, the Docker build should complete successfully without the Prisma generate error in the deploy stage.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

Free review on us!

CodeRabbit is offering free reviews until Wed Dec 17 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

…bian binary target

Co-authored-by: abhalala <121454781+abhalala@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Docker build failure during deploy stage for Prisma Fix Docker build: Copy pre-generated Prisma client instead of regenerating in deploy stage Dec 16, 2025
Copilot AI requested a review from abhalala December 16, 2025 08:56
@abhalala abhalala marked this pull request as ready for review December 16, 2025 08:59
@abhalala abhalala merged commit b5bbd0b into main Dec 16, 2025
2 of 3 checks passed
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.

2 participants