# Build the project from source using a multi-stage Dockerfile
# Stage 1: Build
FROM node:18-alpine AS builder
WORKDIR /app
# Install dependencies (including devDependencies necessary for build)
COPY package.json package.json
RUN npm install
# Remove the stray babel package and install babel-cli for Babel v6 CLI
RUN npm uninstall babel
RUN npm install --no-save babel-cli
# Copy source code
COPY . .
# Build: use Babel directly (non-watch) to produce dist
RUN ./node_modules/.bin/babel src --out-dir dist
# Stage 2: Runtime image
FROM node:18-alpine
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /app/dist /app/dist
# Copy package.json for consumers that may rely on it
COPY package.json package.json
# Default command
CMD ["node","-e","console.log('Choreographer-js container ready. dist built at /app/dist')"]