diff --git a/Dockerfile b/Dockerfile index 75d54e9..85c9790 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,13 +21,15 @@ WORKDIR /root COPY ./mermaidcli/package*.json ./ COPY ./mermaidcli/puppeteer-config.json ./ -# Install Node dependencies -RUN npm ci --only=production && npm cache clean --force +# 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 FROM node:20-bookworm-slim -# Install system dependencies for Puppeteer +# Install system dependencies for Chrome/Puppeteer ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ ca-certificates \ @@ -64,6 +66,10 @@ RUN apt-get update && apt-get install -y \ libxrender1 \ libxss1 \ libxtst6 \ + libxshmfence1 \ + libdrm2 \ + libxkbcommon0 \ + libatspi2.0-0 \ lsb-release \ wget \ xdg-utils \ @@ -75,15 +81,30 @@ WORKDIR /root # Copy Go executable COPY --from=go-builder /root/bin/app ./app -# Copy Node.js dependencies and mermaid CLI +# 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 + +# 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 # 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 @@ -91,5 +112,6 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ # Expose port EXPOSE 80 -# Run the application +# Run the application with dynamic Chrome path +ENTRYPOINT ["/root/start.sh"] CMD ["./app", "--allow-all-origins=true", "--mermaid=./node_modules/.bin/mmdc", "--in=./in", "--out=./out", "--puppeteer=./puppeteer-config.json"] diff --git a/test_bar_chart.mmd b/test_bar_chart.mmd new file mode 100644 index 0000000..9255c84 --- /dev/null +++ b/test_bar_chart.mmd @@ -0,0 +1,10 @@ +%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#ff6b6b", "primaryTextColor": "#fff", "primaryBorderColor": "#ff4757", "lineColor": "#5f27cd", "secondaryColor": "#00d2d3", "tertiaryColor": "#ff9ff3"}}}%% +xychart-beta + title "Monthly Website Performance Metrics - 2024" + x-axis [Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] + y-axis "Metrics Count" 0 --> 120000 + + bar "Unique Visitors" [45000, 52000, 48000, 67000, 72000, 85000, 91000, 88000, 95000, 102000, 108000, 115000] + bar "Page Views" [89000, 104000, 96000, 134000, 144000, 170000, 182000, 176000, 190000, 204000, 216000, 230000] + bar "Sessions" [38000, 44000, 41000, 58000, 62000, 73000, 78000, 75000, 82000, 88000, 93000, 99000] + bar "Bounce Rate %" [45, 42, 48, 38, 35, 32, 30, 33, 29, 27, 25, 23]