ARG
FROM node:18-alpine as base WORKDIR /server FROM base as buildARG NEXT_PUBLIC_API_URLCOPY package*.json ./RUN npm ciCOPY . ./RUN npx prisma generateRUN npm run buildFROM base as productionCOPY --from=build /server/build /server/buildCOPY --from=build /server/node_modules /server/node_modulesCOPY --from=build /server/prisma /server/prismaCOPY --from=build /server/.env* /server/COPY --from=build /server/startup.sh /server/EXPOSE 8080ENV PORT 8080CMD ["node", "/server/build/index.js"]
FROM node:18-alpine AS base RUN apk add --no-cache libc6-compat# BuildFROM base AS builder WORKDIR /appCOPY package*.json ./RUN npm installCOPY . .RUN npm run build# ProductionFROM base AS productionWORKDIR /appRUN addgroup --system --gid 1001 nodejsRUN adduser --system --uid 1001 nextjs# Set the correct permission for prerender cacheRUN mkdir .nextRUN chown nextjs:nodejs .nextCOPY --from=builder /app/package*.json ./COPY --from=builder /app/.next ./.nextCOPY --from=builder /app/public ./publicCOPY --from=builder /app/node_modules ./node_modulesUSER nextjsEXPOSE 3000ENV PORT 3000ENV HOSTNAME "0.0.0.0"CMD ["npm", "start"]