fix: start Xvfb before Node so Chrome has a display
Without Xvfb running, Chrome exits immediately with code 1. The base sitespeedio image normally handles this via its own entrypoint script; we now replicate that with start.sh. Also drop --headless (breaks visual metrics) and add --disable-gpu for stable Chrome rendering inside Docker. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -17,6 +17,8 @@ RUN npm install --omit=dev
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
# Create persistent directories
|
||||
RUN mkdir -p /data/reports
|
||||
|
||||
@@ -33,8 +35,6 @@ ENV PORT=3132 \
|
||||
|
||||
EXPOSE 3132
|
||||
|
||||
# Override the base image's ENTRYPOINT (which is "sitespeed.io") so that
|
||||
# Docker doesn't prepend it to our CMD, causing sitespeed.io to treat
|
||||
# "node" as a URL to test.
|
||||
ENTRYPOINT ["node"]
|
||||
CMD ["app.js"]
|
||||
# start.sh boots Xvfb (virtual display for Chrome/Firefox) then runs the app.
|
||||
# This mirrors what the base image's own entrypoint does.
|
||||
ENTRYPOINT ["/app/start.sh"]
|
||||
|
||||
@@ -22,17 +22,18 @@ export function runTest(job, onLine) {
|
||||
'--sustainable.enable',
|
||||
'--axe.enable',
|
||||
'--coach',
|
||||
'--headless',
|
||||
];
|
||||
|
||||
if (job.mobile) {
|
||||
args.push('--mobile');
|
||||
}
|
||||
|
||||
// In Docker we need --xvfb false and --browsertime.chrome.args=no-sandbox
|
||||
// Chrome needs these flags when running inside Docker
|
||||
if (process.env.IN_DOCKER) {
|
||||
args.push('--browsertime.chrome.args', 'no-sandbox');
|
||||
args.push('--browsertime.chrome.args', 'disable-dev-shm-usage');
|
||||
// Disable GPU compositing — not needed in Xvfb and can cause crashes
|
||||
args.push('--browsertime.chrome.args', 'disable-gpu');
|
||||
}
|
||||
|
||||
onLine(`[runner] Starting: node ${args.slice(0, 3).join(' ')} ...`);
|
||||
|
||||
12
start.sh
Normal file
12
start.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Start virtual framebuffer so Chrome/Firefox have a display to render into.
|
||||
# This is what the base sitespeedio/sitespeed.io image's entrypoint does.
|
||||
Xvfb :99 -ac -screen 0 1920x1080x24 +extension RANDR &
|
||||
export DISPLAY=:99
|
||||
|
||||
# Give Xvfb a moment to initialise
|
||||
sleep 1
|
||||
|
||||
exec node /app/app.js
|
||||
Reference in New Issue
Block a user