updated mermaid-cli
This commit is contained in:
143
Dockerfile
143
Dockerfile
@@ -1,78 +1,95 @@
|
||||
# This stage builds the go executable.
|
||||
FROM golang:1.19.3-buster as go
|
||||
# Multi-stage build
|
||||
|
||||
# Stage 1: Build the Go executable
|
||||
FROM golang:1.21-bookworm as go-builder
|
||||
|
||||
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.
|
||||
FROM debian:buster-slim
|
||||
|
||||
FROM node:18.10.0-buster-slim as node
|
||||
# Stage 2: Setup Node.js environment with mermaid CLI
|
||||
FROM node:20-bookworm-slim as node-builder
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
# copy the mermaidcli node package into the container and install
|
||||
COPY ./mermaidcli/* ./
|
||||
# Copy mermaid CLI package files
|
||||
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
|
||||
RUN apt-get update 2>/dev/null && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
gconf-service \
|
||||
libasound2 \
|
||||
libatk1.0-0 \
|
||||
libatk-bridge2.0-0 \
|
||||
libc6 \
|
||||
libcairo2 \
|
||||
libcups2 \
|
||||
libdbus-1-3 \
|
||||
libexpat1 \
|
||||
libfontconfig1 \
|
||||
libgcc1 \
|
||||
libgconf-2-4 \
|
||||
libgdk-pixbuf2.0-0 \
|
||||
libglib2.0-0 \
|
||||
libgtk-3-0 \
|
||||
libnspr4 \
|
||||
libpango-1.0-0 \
|
||||
libpangocairo-1.0-0 \
|
||||
libstdc++6 \
|
||||
libx11-6 \
|
||||
libx11-xcb1 \
|
||||
libxcb1 \
|
||||
libxcomposite1 \
|
||||
libxcursor1 \
|
||||
libxdamage1 \
|
||||
libxext6 \
|
||||
libxfixes3 \
|
||||
libxi6 \
|
||||
libxrandr2 \
|
||||
libxrender1 \
|
||||
libxss1 \
|
||||
libxtst6 \
|
||||
libxcb-dri3-0 \
|
||||
libgbm1 \
|
||||
ca-certificates \
|
||||
fonts-liberation \
|
||||
libappindicator1 \
|
||||
libnss3 \
|
||||
lsb-release \
|
||||
xdg-utils \
|
||||
wget \
|
||||
libxshmfence1 \
|
||||
2>/dev/null && rm -rf /var/lib/apt/lists/*;
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
fonts-liberation \
|
||||
libappindicator3-1 \
|
||||
libasound2 \
|
||||
libatk-bridge2.0-0 \
|
||||
libatk1.0-0 \
|
||||
libc6 \
|
||||
libcairo2 \
|
||||
libcups2 \
|
||||
libdbus-1-3 \
|
||||
libexpat1 \
|
||||
libfontconfig1 \
|
||||
libgbm1 \
|
||||
libgcc1 \
|
||||
libglib2.0-0 \
|
||||
libgtk-3-0 \
|
||||
libnspr4 \
|
||||
libnss3 \
|
||||
libpango-1.0-0 \
|
||||
libpangocairo-1.0-0 \
|
||||
libstdc++6 \
|
||||
libx11-6 \
|
||||
libx11-xcb1 \
|
||||
libxcb1 \
|
||||
libxcomposite1 \
|
||||
libxcursor1 \
|
||||
libxdamage1 \
|
||||
libxext6 \
|
||||
libxfixes3 \
|
||||
libxi6 \
|
||||
libxrandr2 \
|
||||
libxrender1 \
|
||||
libxss1 \
|
||||
libxtst6 \
|
||||
lsb-release \
|
||||
wget \
|
||||
xdg-utils \
|
||||
--no-install-recommends && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=go /root/bin/app ./app
|
||||
WORKDIR /root
|
||||
|
||||
RUN mkdir -p ./in
|
||||
RUN mkdir -p ./out
|
||||
RUN chmod 0777 ./in
|
||||
RUN chmod 0777 ./out
|
||||
# Copy Go executable
|
||||
COPY --from=go-builder /root/bin/app ./app
|
||||
|
||||
# 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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user