chartjs-chart-js
SUCCESS
29m 41s
History Source
SummaryIterations2Transcript31Dockerfile
Dockerfile55 lines · 1169 chars
FROM node:18-bullseye-slim AS builder

# Install build dependencies needed for node-gyp and building the project
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    python3 \
    make \
    g++ \
    ca-certificates \
    curl \
  && rm -rf /var/lib/apt/lists/*

# Install the exact pnpm version used by this project
RUN npm i -g pnpm@8.13.0

WORKDIR /app

# Copy lockfile first for efficient rebuilding
COPY package.json pnpm-lock.yaml ./

# Install dependencies (workspace-aware)
RUN pnpm install

# Copy the rest of the source
COPY . .

# Build from source
RUN pnpm run build

# Quick verification of build outputs
RUN ls -la dist || true
RUN ls -la auto || true
RUN ls -la helpers || true

# Runtime stage
FROM node:18-bullseye-slim AS runtime

# Create a non-root user to satisfy security best practices
RUN groupadd -r app && useradd -r -g app app

WORKDIR /app

# Copy build artifacts from builder
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/auto /app/auto
COPY --from=builder /app/helpers /app/helpers

# Ensure proper permissions
RUN chown -R app:app /app

USER app

# Simple smoke test on startup
CMD ["node","-v"]