All checks were successful
Build and Push Docker Image / docker (push) Successful in 3m7s
63 lines
2.0 KiB
Docker
63 lines
2.0 KiB
Docker
FROM node:20-bookworm-slim
|
|
|
|
WORKDIR /metrics
|
|
|
|
# Install Chromium from Debian and runtime deps + fonts
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends \
|
|
# runtime deps used by chromium headless
|
|
chromium \
|
|
libnss3 libxss1 libx11-xcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
|
|
libxkbcommon0 libxrandr2 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0 \
|
|
libgbm1 libasound2 fonts-liberation \
|
|
# optional fonts for broader charset support
|
|
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
|
|
# helpers
|
|
curl unzip ca-certificates; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Prevent Puppeteer from downloading Chromium
|
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
|
|
# Force flags via a wrapper so no X/Wayland or sandbox is used
|
|
# We call Debian's chromium executable (usually /usr/bin/chromium or chromium-browser)
|
|
RUN set -eux; \
|
|
CHROME_BIN="$(command -v chromium || command -v chromium-browser)"; \
|
|
printf '%s\n' \
|
|
'#!/usr/bin/env bash' \
|
|
"exec ${CHROME_BIN} \\" \
|
|
' --no-sandbox --disable-setuid-sandbox \\' \
|
|
' --headless=new --disable-gpu --disable-dev-shm-usage \\' \
|
|
' --no-zygote --no-first-run \\' \
|
|
' --ozone-platform=none --disable-features=UseOzonePlatform \\' \
|
|
' "$@"' \
|
|
> /usr/local/bin/chrome-wrapper; \
|
|
chmod +x /usr/local/bin/chrome-wrapper
|
|
|
|
# Point puppeteer to the wrapper (guarantees the flags are applied)
|
|
ENV PUPPETEER_EXECUTABLE_PATH=/usr/local/bin/chrome-wrapper
|
|
|
|
# Optional envs the app may read
|
|
ENV METRICS_BROWSER=chromium
|
|
ENV METRICS_BROWSER_HEADLESS=true
|
|
ENV METRICS_BROWSER_ARGS=""
|
|
ENV METRICS_TRUST_PROXY=1
|
|
|
|
# Install JS deps
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
|
|
# Copy source and build
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Entrypoint that just runs the app; flags are injected by chrome-wrapper
|
|
RUN printf '%s\n' \
|
|
'#!/usr/bin/env bash' \
|
|
'set -euo pipefail' \
|
|
'exec npm start' \
|
|
> /usr/local/bin/metrics-entrypoint && chmod +x /usr/local/bin/metrics-entrypoint
|
|
|
|
ENTRYPOINT ["/usr/local/bin/metrics-entrypoint"]
|