# Install dependencies only when needed FROM node:19-alpine AS deps WORKDIR LEcoffre COPY package.json ./ RUN npm install --frozen-lockfile # Rebuild the source code only when needed FROM node:19-alpine AS builder WORKDIR LEcoffre COPY . . COPY --from=deps LEcoffre/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 RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser . COPY --from=builder --chown=lecoffreuser LEcoffre/node_modules ./node_modules COPY --from=builder --chown=lecoffreuser LEcoffre/public ./public COPY --from=builder --chown=lecoffreuser LEcoffre/dist/front ./src/front COPY --from=builder --chown=lecoffreuser LEcoffre/.next ./.next COPY --from=builder --chown=lecoffreuser LEcoffre/package.json ./package.json #COPY --from=builder --chown=lecoffreuser src/front/next.config.js ./next.config.js USER lecoffreuser CMD ["npm", "run web:start"]