FROM node:20-slim as builder
# Install system dependencies required by Puppeteer and headless Chromium usage
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk1.0-0 libatk-bridge2.0-0 \
libgbm1 libxss1 xdg-utils libnss3 libx11-xcb1 libgtk-3-0 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy the repository and install dependencies for all workspaces
COPY . .
RUN npm install --workspaces
# Build all packages in the monorepo (uses workspaces definitions in package.json)
RUN npm run build-pkg --workspaces
FROM node:20-slim as runtime
# Install the same system dependencies for Puppeteer at runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk1.0-0 libatk-bridge2.0-0 \
libgbm1 libxss1 xdg-utils libnss3 libx11-xcb1 libgtk-3-0 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy built artifacts from the builder stage
COPY --from=builder /workspace /workspace
# Default entrypoint is the MemLab CLI runner
ENTRYPOINT ["node", "packages/cli/dist/index.js"]
CMD ["--help"]