# syntax=docker/dockerfile:1
FROM node:24-slim AS builder
WORKDIR /app
# Install dependencies needed to build the project (including devDependencies)
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the source and build from source
COPY . .
RUN npm run build
# Final runtime image
FROM node:24-slim
WORKDIR /app
# Copy built artifacts from builder stage
COPY --from=builder /app/dist ./dist
# Copy package manifests and install production dependencies only, skipping scripts (e.g., husky)
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/package-lock.json ./package-lock.json
RUN npm ci --production --ignore-scripts
# Copy verification script
COPY ./scripts/verify-container.js ./verify-container.js
# Run verification script at startup
CMD ["node", "./verify-container.js"]