# ---- Build stage ---- FROM node:20-alpine AS build WORKDIR /app COPY package.json ./ RUN npm install COPY tsconfig.json ./ COPY src/ ./src/ RUN npm run build && npm prune --omit=dev # ---- Runtime stage ---- FROM node:20-alpine WORKDIR /app RUN addgroup -S appgroup && adduser -S appuser -G appgroup COPY --from=build /app/dist ./dist COPY --from=build /app/node_modules ./node_modules COPY package.json ./ RUN chown -R appuser:appgroup /app USER appuser EXPOSE 3000 HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \ CMD wget -qO- http://localhost:3000/health | grep -q 'UP' || exit 1 CMD ["node", "--require", "./dist/tracing.js", "dist/main"]