more updates

This commit is contained in:
Matt 2025-05-24 11:27:00 +02:00
parent 83a04ccfc3
commit f486598b8c
1 changed files with 12 additions and 35 deletions

View File

@ -12,21 +12,7 @@ COPY internal/ ./internal/
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/app cmd/app/main.go
# Stage 2: Setup Node.js environment with mermaid CLI
FROM node:20-bookworm-slim as node-builder
WORKDIR /root
# Copy mermaid CLI package files
COPY ./mermaidcli/package*.json ./
COPY ./mermaidcli/puppeteer-config.json ./
# Install Node dependencies and Chrome via Puppeteer
RUN npm ci --only=production && \
npx puppeteer browsers install chrome-headless-shell && \
npm cache clean --force
# Stage 3: Final runtime image
# Stage 2: Setup Node.js environment with mermaid CLI and Chrome
FROM node:20-bookworm-slim
# Install system dependencies for Chrome/Puppeteer
@ -81,30 +67,22 @@ WORKDIR /root
# Copy Go executable
COPY --from=go-builder /root/bin/app ./app
# Copy Node.js dependencies and mermaid CLI with Chrome
COPY --from=node-builder /root/node_modules ./node_modules
COPY --from=node-builder /root/package*.json ./
COPY --from=node-builder /root/puppeteer-config.json ./
COPY --from=node-builder /root/.cache /root/.cache
# Copy mermaid CLI package files
COPY ./mermaidcli/package*.json ./
COPY ./mermaidcli/puppeteer-config.json ./
# Set Puppeteer environment variables and dynamically find Chrome
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
RUN CHROME_PATH=$(find /root/.cache/puppeteer -name "chrome-headless-shell" -type f 2>/dev/null | head -1) && \
echo "export PUPPETEER_EXECUTABLE_PATH='$CHROME_PATH'" >> /root/.bashrc && \
echo "Found Chrome at: $CHROME_PATH" && \
chmod +x "$CHROME_PATH" 2>/dev/null || true
# Install Node dependencies and Chrome in single layer
RUN npm ci --only=production && \
npx puppeteer browsers install chrome-headless-shell && \
npm cache clean --force
# Set environment variables - let Puppeteer find Chrome automatically
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false
# Create directories for input/output
RUN mkdir -p ./in ./out && \
chmod 0777 ./in ./out
# Create startup script to set Chrome path dynamically
RUN echo '#!/bin/bash\n\
export PUPPETEER_EXECUTABLE_PATH=$(find /root/.cache/puppeteer -name "chrome-headless-shell" -type f 2>/dev/null | head -1)\n\
echo "Using Chrome at: $PUPPETEER_EXECUTABLE_PATH"\n\
exec "$@"' > /root/start.sh && \
chmod +x /root/start.sh
# 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
@ -112,6 +90,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
# Expose port
EXPOSE 80
# Run the application with dynamic Chrome path
ENTRYPOINT ["/root/start.sh"]
# Run the application directly
CMD ["./app", "--allow-all-origins=true", "--mermaid=./node_modules/.bin/mmdc", "--in=./in", "--out=./out", "--puppeteer=./puppeteer-config.json"]