# Multi-stage build for jCarousel library
FROM node:22.22.3-alpine3.23 AS builder
# Install build dependencies required by Grunt-based build
RUN apk add --no-cache python3 make g++
WORKDIR /build
# Copy package manifest and install dependencies
COPY package.json package-lock.json ./
RUN npm install
# Copy the rest of the source and build
COPY . .
RUN npm run dist
# Final runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /build/dist ./dist
# Copy package manifest for reference (optional at runtime)
COPY package.json ./
# Copy runtime smoke test script into the image
COPY verify-dist.js /usr/local/bin/verify-dist.js
RUN chmod +x /usr/local/bin/verify-dist.js
# Entry point that verifies dist contents at startup
CMD ["node", "/usr/local/bin/verify-dist.js"]