diff --git a/Dockerfile b/Dockerfile index 6f4bc72..ddea050 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,9 +26,15 @@ COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static -# Prisma needs the schema + engine + CLI to run migrate deploy at startup. +# Prisma needs the schema + migrations + CLI + engines to run migrate deploy at +# startup. We copy the FULL packages (not the .bin symlink) so the CLI's bundled +# .wasm files resolve relative to node_modules/prisma/build/, and the entrypoint +# invokes the real entry path directly (see docker-entrypoint.sh). +# - prisma/ : schema.prisma + migrations/ +# - node_modules/prisma: CLI + prisma_schema_build_bg.wasm and friends +# - node_modules/@prisma: engines (schema-engine for migrate) + client runtime +# - node_modules/.prisma: generated client + linux-musl query engine COPY --from=builder /app/prisma ./prisma -COPY --from=builder /app/node_modules/.bin/prisma ./node_modules/.bin/prisma COPY --from=builder /app/node_modules/prisma ./node_modules/prisma COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 48bd329..916543b 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,8 +2,11 @@ set -e # Apply pending migrations against the database, then start the server. +# Invoke the real CLI entry (NOT the .bin/prisma symlink): Node resolves the +# bundled .wasm files relative to the script's own directory, so calling the +# symlink would look for them under node_modules/.bin/ and fail with ENOENT. echo "Running prisma migrate deploy…" -./node_modules/.bin/prisma migrate deploy +node node_modules/prisma/build/index.js migrate deploy # Ensure the upload directory exists in the mounted volume. mkdir -p "${UPLOAD_DIR:-/data/uploads}" diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 311231e..71d1004 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,8 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + // native = host platform (builder/runner are both node:20-alpine = musl). + // The explicit musl target guards the runtime engine in the final image. + binaryTargets = ["native", "linux-musl-openssl-3.0.x"] } datasource db {