darryl
darryl
PPrisma
Created by darryl on 12/10/2024 in #help-and-questions
Working Build to Non-working Build, OpenSSL & Platform Issues, Docker, Linux, Mac
Thanks for letting me know, it's appreciated.
8 replies
PPrisma
Created by darryl on 12/10/2024 in #help-and-questions
Working Build to Non-working Build, OpenSSL & Platform Issues, Docker, Linux, Mac
A mixture of adding:
binaryTargets = ["native", "linux-musl"]
binaryTargets = ["native", "linux-musl"]
and updating my Dockerfile have resolved this issue. Dockerfile:
FROM node:22-alpine AS base

# Install dependencies required by Prisma and Node.js
RUN apk add --no-cache libc6-compat openssl git bash

WORKDIR /app

# Copy only schema.prisma for generating Prisma Client
COPY ./prisma ./prisma

# Install dependencies and generate Prisma Client
FROM base AS prisma
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile
RUN npx prisma generate

# Build the application
FROM base AS builder
WORKDIR /app
COPY --from=prisma /app/node_modules ./node_modules
COPY . .
ARG DATABASE_URL=${DATABASE_URL}
RUN corepack enable pnpm && pnpm run build

# Prepare the runtime environment
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

# Add Node.js user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Copy build output and necessary files
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.js ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD HOSTNAME="0.0.0.0" node server.js
FROM node:22-alpine AS base

# Install dependencies required by Prisma and Node.js
RUN apk add --no-cache libc6-compat openssl git bash

WORKDIR /app

# Copy only schema.prisma for generating Prisma Client
COPY ./prisma ./prisma

# Install dependencies and generate Prisma Client
FROM base AS prisma
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile
RUN npx prisma generate

# Build the application
FROM base AS builder
WORKDIR /app
COPY --from=prisma /app/node_modules ./node_modules
COPY . .
ARG DATABASE_URL=${DATABASE_URL}
RUN corepack enable pnpm && pnpm run build

# Prepare the runtime environment
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

# Add Node.js user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Copy build output and necessary files
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.js ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD HOSTNAME="0.0.0.0" node server.js
8 replies
PPrisma
Created by darryl on 12/10/2024 in #help-and-questions
Working Build to Non-working Build, OpenSSL & Platform Issues, Docker, Linux, Mac
FWIW installing openssl at build does not solve the issue. Nor does "Add "linux-musl" to binaryTargets in the "schema.prisma" file and run prisma generate after saving it" 😭
8 replies
PPrisma
Created by darryl on 12/10/2024 in #help-and-questions
Working Build to Non-working Build, OpenSSL & Platform Issues, Docker, Linux, Mac
And my docker-compose.yml:
services:
app:
platform: linux/x86_64
build:
context: .
args:
DATABASE_URL: ${DATABASE_URL}
environment:
- DATABASE_URL=${DATABASE_URL}
ports:
- "3000:3000"
services:
app:
platform: linux/x86_64
build:
context: .
args:
DATABASE_URL: ${DATABASE_URL}
environment:
- DATABASE_URL=${DATABASE_URL}
ports:
- "3000:3000"
8 replies
PPrisma
Created by darryl on 12/10/2024 in #help-and-questions
Working Build to Non-working Build, OpenSSL & Platform Issues, Docker, Linux, Mac
Here is my Dockerfile:
FROM node:22-alpine AS base

# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Update CA certificates
#RUN apt-get update && apt-get install -y ca-certificates

# Install dependencies based on the preferred package manager
COPY package.json pnpm-lock.yaml ./
COPY ./prisma/schema.prisma ./prisma/schema.prisma
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app

# Update CA certificates
#RUN apt-get update && apt-get install -y ca-certificates
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ARG DATABASE_URL=${DATABASE_URL}

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD HOSTNAME="0.0.0.0" node server.js
FROM node:22-alpine AS base

# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Update CA certificates
#RUN apt-get update && apt-get install -y ca-certificates

# Install dependencies based on the preferred package manager
COPY package.json pnpm-lock.yaml ./
COPY ./prisma/schema.prisma ./prisma/schema.prisma
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app

# Update CA certificates
#RUN apt-get update && apt-get install -y ca-certificates
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ARG DATABASE_URL=${DATABASE_URL}

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD HOSTNAME="0.0.0.0" node server.js
8 replies
PPrisma
Created by darryl on 12/10/2024 in #help-and-questions
Working Build to Non-working Build, OpenSSL & Platform Issues, Docker, Linux, Mac
If anyone can offer any advice on how to resolve this issue, it would be much appreciated. I'm working on Mac, building for Linux. Dockerfile & docker-compose.yml to follow:
33.60 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
33.60 Please manually install OpenSSL and try installing Prisma again.
33.60 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
33.60 Please manually install OpenSSL and try installing Prisma again.
33.61 Error [PrismaClientInitializationError]: Unable to require(`/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/.prisma/client/libquery_engine-linux-musl.so.node`).
33.61 The Prisma engines do not seem to be compatible with your system. Please refer to the documentation about Prisma's system requirements: https://pris.ly/d/system-requirements
33.61
33.61 Details: Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/.prisma/client/libquery_engine-linux-musl.so.node)
33.61 at Object.loadLibrary (/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/runtime/library.js:111:10243)
33.61 at async _r.loadEngine (/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/runtime/library.js:112:448)
33.61 at async _r.instantiateLibrary (/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/runtime/library.js:111:12599) {
33.61 clientVersion: '5.22.0',
33.61 errorCode: undefined
33.61 }
33.60 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
33.60 Please manually install OpenSSL and try installing Prisma again.
33.60 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
33.60 Please manually install OpenSSL and try installing Prisma again.
33.61 Error [PrismaClientInitializationError]: Unable to require(`/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/.prisma/client/libquery_engine-linux-musl.so.node`).
33.61 The Prisma engines do not seem to be compatible with your system. Please refer to the documentation about Prisma's system requirements: https://pris.ly/d/system-requirements
33.61
33.61 Details: Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/.prisma/client/libquery_engine-linux-musl.so.node)
33.61 at Object.loadLibrary (/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/runtime/library.js:111:10243)
33.61 at async _r.loadEngine (/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/runtime/library.js:112:448)
33.61 at async _r.instantiateLibrary (/app/node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/runtime/library.js:111:12599) {
33.61 clientVersion: '5.22.0',
33.61 errorCode: undefined
33.61 }
8 replies
PPrisma
Created by darryl on 7/5/2023 in #help-and-questions
Error: @prisma/client did not initialize yet. Please run "prisma generate"
This was solved by changing the Node version in my Dockerfile as suggested in this thread https://github.com/prisma/prisma/issues/14073. Really weird for this issue to seemingly come out of nowhere but it's working 🤷‍♂️
2 replies