FROM node:18-bullseye-slim AS builder
# Build-time dependencies for native modules
ENV npm_config_loglevel=warn
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy the entire repository
COPY . .
# Install dependencies if a root package.json exists
RUN if [ -f package.json ]; then npm ci --workspaces=false; fi
# Attempt to build/compile each sample if possible
RUN for d in */ ; do if [ -f "$d/package.json" ]; then (cd "$d" && npm run compile 2>/dev/null || true); fi; done
FROM node:18-bullseye-slim
WORKDIR /workspace
# Copy built artifacts from the builder stage
COPY --from=builder /workspace /workspace
# Default to an interactive shell; this container is for exploring the repo
CMD ["bash"]