# Install dependencies only when needed FROM node:19-alpine AS deps WORKDIR lecoffre-front COPY package.json ./ RUN npm install --frozen-lockfile # Rebuild the source code only when needed FROM node:19-alpine AS builder WORKDIR lecoffre-front COPY . . COPY --from=deps lecoffre-front/node_modules ./node_modules RUN npm run build # Production image, copy all the files and run next FROM node:19-alpine AS production WORKDIR lecoffre-front RUN adduser -D lecoffre-frontuser --uid 10000 && chown -R lecoffre-frontuser . COPY --from=builder --chown=lecoffre-frontuser lecoffre-front/node_modules ./node_modules COPY --from=builder --chown=lecoffre-frontuser lecoffre-front/public ./public COPY --from=builder --chown=lecoffre-frontuser lecoffre-front/.next ./.next COPY --from=builder --chown=lecoffre-frontuser lecoffre-front/next.config.js ./next.config.js COPY --from=builder --chown=lecoffre-frontuser lecoffre-front/package.json ./package.json USER lecoffre-frontuser CMD ["npm", "run", "start"] EXPOSE 3000