# syntax=docker/dockerfile:1 # ---- deps: install once, reused by the build stage ---- FROM node:24-alpine AS deps WORKDIR /app # Prisma's engine binaries need OpenSSL; libc6-compat smooths over a few # other native-module quirks on Alpine. RUN apk add --no-cache libc6-compat openssl COPY package.json package-lock.json ./ RUN npm ci # ---- build: generate the Prisma client and compile the Next.js app ---- FROM node:24-alpine AS build WORKDIR /app RUN apk add --no-cache openssl COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npx prisma generate RUN npm run build # ---- runtime ---- # Not using Next's `output: "standalone"` here: its dependency tracing # only follows what the server bundle imports, so it wouldn't include the # Prisma CLI, which this image invokes as a separate process (via # docker-entrypoint.sh) to run migrations on every container start. Copying # the full node_modules is a simpler, more reliable trade for a # single self-hosted instance. FROM node:24-alpine AS runtime WORKDIR /app ENV NODE_ENV=production RUN apk add --no-cache openssl COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/.next ./.next COPY --from=build /app/public ./public COPY --from=build /app/prisma ./prisma COPY --from=build /app/lib ./lib COPY --from=build /app/prisma.config.ts ./prisma.config.ts COPY --from=build /app/package.json ./package.json COPY --from=build /app/next.config.ts ./next.config.ts COPY docker-entrypoint.sh ./docker-entrypoint.sh RUN chmod +x docker-entrypoint.sh EXPOSE 3000 ENTRYPOINT ["./docker-entrypoint.sh"] CMD ["npm", "run", "start"]