Previously Working Dockerfile No Longer Works
FROM node:lts-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
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
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN npx prisma generate
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
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs prisma ./prisma/
USER nextjs
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["sh", "-c", "npx prisma migrate deploy && npm run seed && node server.js"]
FROM node:lts-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
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
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN npx prisma generate
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
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs prisma ./prisma/
USER nextjs
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["sh", "-c", "npx prisma migrate deploy && npm run seed && node server.js"]
2024-12-10 01:11:54 npm warn exec The following package was not found and will be installed: [email protected]
2024-12-10 01:11:59 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
2024-12-10 01:11:59 Please manually install OpenSSL and try installing Prisma again.
2024-12-10 01:11:59 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
2024-12-10 01:11:59 Please manually install OpenSSL and try installing Prisma again.
2024-12-10 01:11:59 Prisma schema loaded from prisma/schema.prisma
2024-12-10 01:11:59 Datasource "db": PostgreSQL database "REDACTED", schema "public" at "REDACTED"
2024-12-10 01:11:59
2024-12-10 01:11:59 Error: Could not parse schema engine response: SyntaxError: Unexpected token 'E', "Error load"... is not valid JSON
2024-12-10 01:11:59 npm notice
2024-12-10 01:11:59 npm notice New patch version of npm available! 10.9.0 -> 10.9.2
2024-12-10 01:11:59 npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.9.2
2024-12-10 01:11:59 npm notice To update run: npm install -g [email protected]
2024-12-10 01:11:59 npm notice
2024-12-10 01:11:54 npm warn exec The following package was not found and will be installed: [email protected]
2024-12-10 01:11:59 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
2024-12-10 01:11:59 Please manually install OpenSSL and try installing Prisma again.
2024-12-10 01:11:59 prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
2024-12-10 01:11:59 Please manually install OpenSSL and try installing Prisma again.
2024-12-10 01:11:59 Prisma schema loaded from prisma/schema.prisma
2024-12-10 01:11:59 Datasource "db": PostgreSQL database "REDACTED", schema "public" at "REDACTED"
2024-12-10 01:11:59
2024-12-10 01:11:59 Error: Could not parse schema engine response: SyntaxError: Unexpected token 'E', "Error load"... is not valid JSON
2024-12-10 01:11:59 npm notice
2024-12-10 01:11:59 npm notice New patch version of npm available! 10.9.0 -> 10.9.2
2024-12-10 01:11:59 npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.9.2
2024-12-10 01:11:59 npm notice To update run: npm install -g [email protected]
2024-12-10 01:11:59 npm notice
7 Replies
{
"name": "REDACTED",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"seed": "node prisma/seed.js",
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap --config next-sitemap.config.cjs",
"start": "next start",
"lint": "next lint"
},
"prisma": {
"seed": "node prisma/seed.js"
},
"dependencies": {
"@apollo/client": "^3.11.10",
"@apollo/server": "^4.11.2",
"@as-integrations/next": "^3.2.0",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@graphql-tools/merge": "^9.0.10",
"@mui/icons-material": "^6.1.9",
"@mui/material": "^6.1.9",
"@prisma/client": "^6.0.0",
"axios": "^1.7.7",
"bcrypt": "^5.1.1",
"dateformat": "^5.0.3",
"framer-motion": "^11.11.17",
"graphql": "^16.9.0",
"graphql-tag": "^2.12.6",
"jsonwebtoken": "^9.0.2",
"minio": "^8.0.2",
"next": "15.0.3",
"next-auth": "^4.24.10",
"next-sitemap": "^4.2.3",
"react": "18.3.1",
"react-burger-menu": "^3.1.0",
"react-dom": "18.3.1",
"react-loading-indicators": "^1.0.0",
"sass": "^1.81.0"
},
"devDependencies": {
"@types/dateformat": "^5.0.2",
"@types/graphql": "^14.2.3",
"@types/jsonwebtoken": "^9.0.7",
"@types/minio": "^7.1.0",
"@types/node": "^20.17.9",
"@types/react": "^18.3.12",
"@types/react-burger-menu": "^2.8.7",
"@types/react-dom": "^18",
"prisma": "^6.0.0",
"typescript": "^5.7.2"
}
}
{
"name": "REDACTED",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"seed": "node prisma/seed.js",
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap --config next-sitemap.config.cjs",
"start": "next start",
"lint": "next lint"
},
"prisma": {
"seed": "node prisma/seed.js"
},
"dependencies": {
"@apollo/client": "^3.11.10",
"@apollo/server": "^4.11.2",
"@as-integrations/next": "^3.2.0",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@graphql-tools/merge": "^9.0.10",
"@mui/icons-material": "^6.1.9",
"@mui/material": "^6.1.9",
"@prisma/client": "^6.0.0",
"axios": "^1.7.7",
"bcrypt": "^5.1.1",
"dateformat": "^5.0.3",
"framer-motion": "^11.11.17",
"graphql": "^16.9.0",
"graphql-tag": "^2.12.6",
"jsonwebtoken": "^9.0.2",
"minio": "^8.0.2",
"next": "15.0.3",
"next-auth": "^4.24.10",
"next-sitemap": "^4.2.3",
"react": "18.3.1",
"react-burger-menu": "^3.1.0",
"react-dom": "18.3.1",
"react-loading-indicators": "^1.0.0",
"sass": "^1.81.0"
},
"devDependencies": {
"@types/dateformat": "^5.0.2",
"@types/graphql": "^14.2.3",
"@types/jsonwebtoken": "^9.0.7",
"@types/minio": "^7.1.0",
"@types/node": "^20.17.9",
"@types/react": "^18.3.12",
"@types/react-burger-menu": "^2.8.7",
"@types/react-dom": "^18",
"prisma": "^6.0.0",
"typescript": "^5.7.2"
}
}
try using previous last Node lts version like,
FROM node:22.11.0-alpine AS base
it work for me, i have the same error and i could not find any solution, even tough the docs says 'must use LTS version of node' but i don't know why LTS 22.12 is not workingPosted this in the wrong chat previously... sorry! But I managed to "fix" it. I'm not sure if this is a bad way, but I'm sure someone will correct me if I am wrong. These are my latest files/settings which fixed it.
FROM node:lts-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache openssl
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
RUN apk add --no-cache openssl
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN npx prisma generate
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN apk add --no-cache openssl
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs prisma ./prisma/
USER nextjs
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["sh", "-c", "npx prisma migrate deploy && npm run seed && node server.js"]
FROM node:lts-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache openssl
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
RUN apk add --no-cache openssl
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN npx prisma generate
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN apk add --no-cache openssl
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs prisma ./prisma/
USER nextjs
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["sh", "-c", "npx prisma migrate deploy && npm run seed && node server.js"]
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl", "linux-musl-openssl-3.0.x"]
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl", "linux-musl-openssl-3.0.x"]
}
So the major change you did was replacing:
with
This is strange, you didn't upgrade any dependencies, right?
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache openssl
RUN apk add --no-cache openssl
Mind you I'm using debian as my base, but I had to do this with my binary targets, I doubt this is actually going to help now that I have it typed out but you never know
binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x", "linux-musl", "linux-musl-openssl-3.0.x"]
Debian stable
FROM node:bullseye-slim
Correct
Actually this is half of what I did to get it to work!
if you look in #chat you aren't the only one. This appears to be an alpine problem
I have had zero problems on node slim