FROM node:20-slim
# Create app directory and set workdir
WORKDIR /app
# Install system dependencies for building native modules
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Enable Corepack and ensure Yarn is available
RUN corepack enable
# Install dependencies first (cache-friendly)
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Copy the rest of the repository
COPY . .
# Build from source if a build script is defined (if present in package.json)
# Note: Some projects may not expose a top-level build script; this step is optional and safe.
RUN true
# Expose CLI entry point. Run the local repo's webpack CLI via node.
CMD ["node", "bin/webpack.js"]