updated mermaid-cli

This commit is contained in:
Matt 2025-05-24 11:14:38 +02:00
parent 59cf3052b1
commit b2d2782363
6 changed files with 4728 additions and 324 deletions

View File

@ -1,78 +1,95 @@
# This stage builds the go executable. # Multi-stage build
FROM golang:1.19.3-buster as go
# Stage 1: Build the Go executable
FROM golang:1.21-bookworm as go-builder
WORKDIR /root WORKDIR /root
COPY ./ ./ COPY go.mod go.sum ./
RUN go mod download
RUN go build -o bin/app cmd/app/main.go COPY cmd/ ./cmd/
COPY internal/ ./internal/
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/app cmd/app/main.go
# Final stage that will be pushed. # Stage 2: Setup Node.js environment with mermaid CLI
FROM debian:buster-slim FROM node:20-bookworm-slim as node-builder
FROM node:18.10.0-buster-slim as node
WORKDIR /root WORKDIR /root
# copy the mermaidcli node package into the container and install # Copy mermaid CLI package files
COPY ./mermaidcli/* ./ COPY ./mermaidcli/package*.json ./
COPY ./mermaidcli/puppeteer-config.json ./
RUN npm install && npm cache clean --force; # Install Node dependencies
RUN npm ci --only=production && npm cache clean --force
# Stage 3: Final runtime image
FROM node:20-bookworm-slim
# Install system dependencies for Puppeteer
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update 2>/dev/null && \ RUN apt-get update && apt-get install -y \
apt-get install -y --no-install-recommends \ ca-certificates \
ca-certificates \ fonts-liberation \
gconf-service \ libappindicator3-1 \
libasound2 \ libasound2 \
libatk1.0-0 \ libatk-bridge2.0-0 \
libatk-bridge2.0-0 \ libatk1.0-0 \
libc6 \ libc6 \
libcairo2 \ libcairo2 \
libcups2 \ libcups2 \
libdbus-1-3 \ libdbus-1-3 \
libexpat1 \ libexpat1 \
libfontconfig1 \ libfontconfig1 \
libgcc1 \ libgbm1 \
libgconf-2-4 \ libgcc1 \
libgdk-pixbuf2.0-0 \ libglib2.0-0 \
libglib2.0-0 \ libgtk-3-0 \
libgtk-3-0 \ libnspr4 \
libnspr4 \ libnss3 \
libpango-1.0-0 \ libpango-1.0-0 \
libpangocairo-1.0-0 \ libpangocairo-1.0-0 \
libstdc++6 \ libstdc++6 \
libx11-6 \ libx11-6 \
libx11-xcb1 \ libx11-xcb1 \
libxcb1 \ libxcb1 \
libxcomposite1 \ libxcomposite1 \
libxcursor1 \ libxcursor1 \
libxdamage1 \ libxdamage1 \
libxext6 \ libxext6 \
libxfixes3 \ libxfixes3 \
libxi6 \ libxi6 \
libxrandr2 \ libxrandr2 \
libxrender1 \ libxrender1 \
libxss1 \ libxss1 \
libxtst6 \ libxtst6 \
libxcb-dri3-0 \ lsb-release \
libgbm1 \ wget \
ca-certificates \ xdg-utils \
fonts-liberation \ --no-install-recommends && \
libappindicator1 \ rm -rf /var/lib/apt/lists/*
libnss3 \
lsb-release \
xdg-utils \
wget \
libxshmfence1 \
2>/dev/null && rm -rf /var/lib/apt/lists/*;
COPY --from=go /root/bin/app ./app WORKDIR /root
RUN mkdir -p ./in # Copy Go executable
RUN mkdir -p ./out COPY --from=go-builder /root/bin/app ./app
RUN chmod 0777 ./in
RUN chmod 0777 ./out
# Copy Node.js dependencies and mermaid CLI
COPY --from=node-builder /root/node_modules ./node_modules
COPY --from=node-builder /root/package*.json ./
COPY --from=node-builder /root/puppeteer-config.json ./
# Create directories for input/output
RUN mkdir -p ./in ./out && \
chmod 0777 ./in ./out
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:80/health || exit 1
# Expose port
EXPOSE 80
# Run the application
CMD ["./app", "--allow-all-origins=true", "--mermaid=./node_modules/.bin/mmdc", "--in=./in", "--out=./out", "--puppeteer=./puppeteer-config.json"] CMD ["./app", "--allow-all-origins=true", "--mermaid=./node_modules/.bin/mmdc", "--in=./in", "--out=./out", "--puppeteer=./puppeteer-config.json"]

20
docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
version: "3.8"
services:
mermaid-server:
build: .
container_name: mermaid-server
ports:
- "7000:80" # Map host port 7000 to container port 80
volumes:
- ./in:/root/in # optional: persist input for caching
- ./out:/root/out # optional: persist output for debugging
environment:
ALLOW_ALL_ORIGINS: "true"
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:80/health"]
interval: 30s
timeout: 10s
start_period: 5s
retries: 3

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/tomwright/mermaid-server module github.com/tomwright/mermaid-server
go 1.15 go 1.21
require ( require (
github.com/tomwright/grace v0.1.2 github.com/tomwright/grace v0.1.2

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,6 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@mermaid-js/mermaid-cli": "^9.1.7" "@mermaid-js/mermaid-cli": "^11.4.2"
} }
} }

View File

@ -0,0 +1,18 @@
quadrantChart
title Website Performance Analysis
x-axis Low Traffic --> High Traffic
y-axis Low Conversion --> High Conversion
quadrant-1 Stars (High Traffic, High Conversion)
quadrant-2 Question Marks (Low Traffic, High Conversion)
quadrant-3 Dogs (Low Traffic, Low Conversion)
quadrant-4 Cash Cows (High Traffic, Low Conversion)
Homepage: [0.8, 0.9]
Product Pages: [0.7, 0.8]
Blog Posts: [0.6, 0.4]
Contact Page: [0.2, 0.7]
About Page: [0.3, 0.3]
Pricing Page: [0.5, 0.8]
Support Page: [0.4, 0.5]
FAQ Page: [0.3, 0.6]