-
Notifications
You must be signed in to change notification settings - Fork 272
Description
i tried containerizing it here is the docker file.
---- Stage 1: The AMD64 Builder (with Firefox) ----
We explicitly set the platform for this stage to amd64
FROM --platform=linux/amd64 amd64/node:22-slim AS builder-amd64
ENV DEBIAN_FRONTEND=noninteractive
1. Install Firefox and its dependencies needed FOR THE BUILD on amd64
RUN apt-get update &&
apt-get install -y --no-install-recommends
tini
firefox-esr
libdbus-glib-1-2
libgtk-3-0
libasound2
pciutils
libgl1
xvfb
xauth
x11-utils
&& rm -rf /var/lib/apt/lists/*
2. Configure Puppeteer to use our system-installed Firefox
ENV PUPPETEER_SKIP_DOWNLOAD=true
PUPPETEER_PRODUCT="firefox"
PUPPETEER_EXECUTABLE_PATH="/usr/bin/firefox-esr"
WORKDIR /app
3. Copy and install dependencies. This happens on a stable amd64 container.
COPY package.json .
RUN npm install
4. Manually create the cache directory.
RUN mkdir /app/cache
5. Warm up the cache. This runs on a stable amd64 environment.
RUN node_modules/.bin/highcharts-export-server
--cache-path /app/cache
-options '{"title":{"text":"Cache Warm-up"}}'
-outfile /dev/null
--puppeteer-args '["--no-sandbox", "--disable-setuid-sandbox"]'
---- Stage 2: The Final S390X Slim Image ----
---- Stage 2: The Final S390X Slim Image ----
FROM s390x/node:22-slim
Install ALL runtime dependencies for Firefox
RUN apt-get update &&
apt-get install -y --no-install-recommends
tini
firefox-esr
libdbus-glib-1-2
libgtk-3-0
libasound2
fonts-liberation
pciutils
libgl1
xvfb
xauth
x11-utils
&& rm -rf /var/lib/apt/lists/*
Pre-create X11 directory with correct permissions
RUN mkdir -p /tmp/.X11-unix &&
chmod 1777 /tmp/.X11-unix &&
mkdir -p /tmp/.ICE-unix &&
chmod 1777 /tmp/.ICE-unix
Set environment variables
ENV PUPPETEER_SKIP_DOWNLOAD=true
PUPPETEER_PRODUCT="firefox"
PUPPETEER_EXECUTABLE_PATH="/usr/bin/firefox-esr"
DISPLAY=:99
XAUTHORITY=/tmp/.Xauthority
Create user and directories
RUN useradd --create-home --shell /bin/bash appuser
WORKDIR /home/appuser/app
Copy artifacts from builder
COPY --from=builder-amd64 --chown=appuser:appuser /app/cache /home/appuser/app/cache
COPY --from=builder-amd64 --chown=appuser:appuser /app/node_modules /home/appuser/app/node_modules
COPY --from=builder-amd64 --chown=appuser:appuser /app/package.json .
Create directories and set permissions
RUN mkdir -p log tmp &&
chown -R appuser:appuser log tmp /tmp/.X11-unix /tmp/.ICE-unix
USER appuser
EXPOSE 3001
ENTRYPOINT ["/usr/bin/tini","--"]
Run with xvfb-run
CMD [
"xvfb-run",
"-a",
"-e", "/dev/stdout",
"--server-args=-screen 0 1920x1080x24 -ac -nolisten tcp",
"node_modules/.bin/highcharts-export-server",
"--enableServer", "1",
"--port", "3001",
"--no-internet",
"--cache-path", "/home/appuser/app/cache",
"--log-dest", "/dev/stdout",
"--puppeteer-args", "["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage", "--disable-gpu", "--no-zygote", "--headless"]"
]