# Image des services API Node du Cloud. APP_DIR choisit le paquet a construire # (API ou CLI de migration) ; les deux partagent la meme methode de build. FROM node:22-alpine AS builder ARG APP_DIR WORKDIR /repo COPY package.json package-lock.json tsconfig.json tsconfig.base.json ./ COPY backend ./backend RUN --mount=type=cache,target=/root/.npm npm ci RUN npm run build --workspace=${APP_DIR} # On ne embarque pas les devDependencies dans l'image de production. RUN npm prune --omit=dev && npm cache clean --force FROM node:22-alpine AS export ARG APP_DIR ENV NODE_ENV=production WORKDIR /repo COPY --from=builder /repo/package.json ./package.json COPY --from=builder /repo/package-lock.json ./package-lock.json COPY --from=builder /repo/node_modules ./node_modules COPY --from=builder /repo/${APP_DIR} ./${APP_DIR} WORKDIR /repo/${APP_DIR} EXPOSE 8080 CMD ["node", "dist/index.js"]