tencent-wujie
SUCCESS
33m 36s
History Source
SummaryIterations2Transcript29Dockerfile
Dockerfile41 lines · 1345 chars
# syntax=docker/dockerfile:1

#  Builder stage: compile the monorepo using pnpm
FROM node:18-bullseye-slim AS builder

# Install essential build tools
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates python3 build-essential \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /workspace

# Install a specific pnpm version for reproducibility
RUN npm i -g pnpm@7.9.5

# Copy repository
COPY . .

# Install dependencies for the workspace with frozen lockfile; only build the wujie-core package via path filter
RUN pnpm install --frozen-lockfile --filter "./packages/wujie-core"

# Build the wujie-core library (lib and esm outputs)
RUN pnpm --filter "./packages/wujie-core" run lib
RUN pnpm --filter "./packages/wujie-core" run esm


# Runtime stage: only keep built artifacts and minimal runtime
FROM node:18-bullseye-slim AS runtime

# Install runtime dependencies (kept lightweight)
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/local/wujie

# Copy build artifacts from builder
COPY --from=builder /workspace/packages/wujie-core/lib /usr/local/wujie/lib
COPY --from=builder /workspace/packages/wujie-core/esm /usr/local/wujie/esm

# Default to a minimal shell; the image primarily serves as a build artifact container
CMD ["/bin/sh"]