mermaid-js-mermaid
SUCCESS
13m 18s
History Source
SummaryIterations1Transcript21Dockerfile
Dockerfile50 lines · 1323 chars
FROM node:22.12.0-alpine3.19

LABEL maintainer="BuildAgent"

USER 0:0

# Install system dependencies needed for building native modules
RUN apk add --no-cache \
      git \
      python3 \
      make \
      g++ \
      cairo-dev \
      pixman-dev \
      pango-dev \
      libjpeg-turbo-dev \
      libpng-dev \
      giflib-dev

# Install pinned pnpm version globally (without relying on Corepack in this base image)
RUN npm i -g pnpm@10.30.3

ENV NODE_OPTIONS="--max_old_space_size=8192"

WORKDIR /mermaid

# Copy manifests first to leverage Docker cache
COPY package.json pnpm-lock.yaml* ./
COPY patches ./patches

# Install dependencies with frozen lockfile; skip scripts to avoid repo-wide build scripts during install
RUN pnpm install --frozen-lockfile --ignore-scripts

# Copy the rest of the source
COPY . .

# Try to build the mermaid package (if build script is not defined in mermaid, skip)
RUN if pnpm -w --filter mermaid run | tr -d '\n' | grep -q 'build'; then pnpm --filter mermaid run build; else echo 'No build script for mermaid, skipping build'; fi

# Create a non-root user for running the app
RUN adduser -D mermaid && chown -R mermaid:mermaid /mermaid

USER mermaid

# Expose ports used by the app
EXPOSE 9000 3333

# Default command to run the dev server for local usage
CMD ["pnpm", "run", "dev"]