fix(dockerfile): correct prisma generate path + add openssl for Alpine detection

Two fixes for Prisma on Alpine Linux:
1. Use /app/node_modules/.bin/prisma (workspace root) instead of
   node_modules/.bin/prisma — pnpm does not hoist binaries into each
   service's local node_modules/.bin, so the previous command silently
   skipped via || true, leaving only the default linux-musl (libssl 1.1) binary.
2. Add openssl to apk packages so Prisma can run 'openssl version' at
   runtime to detect OpenSSL 3.x and load the linux-musl-openssl-3.0.x
   engine binary instead of defaulting to the missing libssl.so.1.1 variant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-07 20:10:07 -08:00
parent aa2b8e3138
commit 7edbea6ff0
1 changed files with 11 additions and 4 deletions

View File

@ -43,7 +43,7 @@ RUN pnpm turbo build --filter='./packages/shared/*' --filter=@it0/${SERVICE_NAME
FROM node:18-alpine
# Install bash (required by Claude Agent SDK Bash tool) + openssh-client (for SSH to managed servers) + su-exec (for privilege drop)
RUN apk add --no-cache bash openssh-client su-exec
RUN apk add --no-cache bash openssh-client su-exec openssl
RUN corepack enable
@ -85,11 +85,18 @@ COPY --from=builder /app/packages/shared/database/src/migrations packages/servic
# Copy Prisma schema and generate client if this service uses @prisma/client.
# prisma is kept in dependencies so it is available after --prod install.
# NOTE: use /app/node_modules/.bin/prisma (workspace root) — pnpm does not hoist
# binaries into each service's node_modules/.bin in a workspace setup.
ARG SERVICE_NAME
COPY --from=builder /app/packages/services/${SERVICE_NAME}/prisma packages/services/${SERVICE_NAME}/prisma/
RUN test -f packages/services/${SERVICE_NAME}/prisma/schema.prisma && \
cd packages/services/${SERVICE_NAME} && \
node_modules/.bin/prisma generate --schema prisma/schema.prisma || true
RUN if [ -f "packages/services/${SERVICE_NAME}/prisma/schema.prisma" ]; then \
echo "Running prisma generate for ${SERVICE_NAME}..." && \
/app/node_modules/.bin/prisma generate \
--schema /app/packages/services/${SERVICE_NAME}/prisma/schema.prisma && \
echo "Prisma generate completed."; \
else \
echo "No prisma/schema.prisma found — skipping prisma generate."; \
fi
WORKDIR /app/packages/services/${SERVICE_NAME}