fix: Prisma OpenSSL engine binary detection on Alpine
All checks were successful
Deploy Canina / deploy (push) Successful in 34s

- Set PRISMA_SCHEMA_ENGINE_BINARY to 3.0.x binary path
- Set PRISMA_QUERY_ENGINE_LIBRARY to 3.0.x library path
- node:20-alpine has libssl.so.3 but no openssl CLI binary
- Prisma detection fails silently, defaults to 1.1.x engines
- Explicit paths bypass detection and use correct binaries
- Remove apk add openssl (not needed, causes build failure without VPN)
- backend Dockerfile: use PRISMA_CLI_BINARY_TARGETS to generate correct client
This commit is contained in:
parsa aghaei 2026-07-29 09:21:39 +03:30
parent 501addc909
commit 431e2b547d
3 changed files with 7 additions and 3 deletions

View File

@ -1,13 +1,12 @@
FROM node:20-alpine AS builder
RUN apk add --no-cache openssl 2>/dev/null || true
WORKDIR /app
COPY package*.json ./
RUN npm ci --prefer-offline --no-audit
RUN npm config set registry http://registry.parsaaghayi.ir/repository/npm-proxy/ && npm ci
COPY . .
ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x
RUN npx prisma generate && npm run build
FROM node:20-alpine
RUN apk add --no-cache openssl 2>/dev/null || true
RUN mkdir -p /app/uploads && chown node:node /app/uploads
WORKDIR /app
COPY --from=builder /app/package*.json ./
@ -16,6 +15,7 @@ COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/prisma/scientificTerms.ts ./prisma/scientificTerms.ts
RUN chown -R node:node /app
ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x
EXPOSE 3000
USER node
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/main"]

View File

@ -32,6 +32,8 @@ services:
- REDIS_HOST=redis_prod
- REDIS_PORT=6379
- PORT=3000
- PRISMA_SCHEMA_ENGINE_BINARY=/app/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x
- PRISMA_QUERY_ENGINE_LIBRARY=/app/node_modules/@prisma/engines/libquery_engine-linux-musl-openssl-3.0.x.so.node
labels:
- "traefik.enable=true"
- "traefik.http.routers.canina-api-prod.rule=Host(`api.canina.ir`)"

View File

@ -32,6 +32,8 @@ services:
- REDIS_HOST=redis_stage
- REDIS_PORT=6379
- PORT=3000
- PRISMA_SCHEMA_ENGINE_BINARY=/app/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x
- PRISMA_QUERY_ENGINE_LIBRARY=/app/node_modules/@prisma/engines/libquery_engine-linux-musl-openssl-3.0.x.so.node
labels:
- "traefik.enable=true"
- "traefik.http.routers.canina-api-stage.rule=Host(`stageapi.canina.ir`)"