FROM node:22.22.3-alpine3.23 AS build
WORKDIR /workspace
# Install dependencies and build (if a build script exists)
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the source and run an optional build
COPY . .
RUN npm run build --if-present
FROM node:22.22.3-alpine3.23
WORKDIR /workspace
# Install runtime dependencies (exclude dev dependencies)
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
# Copy built library into runtime image
COPY --from=build /workspace/lib ./lib
# Copy main package.json to allow consumers to resolve the module
COPY --from=build /workspace/package.json ./package.json
# Do not define a default CMD; tests will supply their own commands