FROM node:14-bullseye-slim AS builder
WORKDIR /workspace
# Install build tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install pnpm matching the repository workflow
RUN npm i -g pnpm@7.9.5
# Copy the repository into the image
COPY . .
# Install dependencies for the whole workspace
RUN pnpm install --frozen-lockfile
# Build the wujie-core library
WORKDIR /workspace/packages/wujie-core
RUN pnpm i
RUN pnpm run lib
# Stage 2: runtime server to serve built artifacts
FROM node:14-bullseye-slim
WORKDIR /app
# Copy built library from builder stage
COPY --from=builder /workspace/packages/wujie-core/lib /dist
# Install a tiny static server to serve dist
RUN npm i -g http-server
EXPOSE 8080
CMD ["http-server", "/dist", "-p", "8080"]