fix: discover sitespeed.js path at build time, export via /sitespeed_env
sitespeed.io is not on PATH in the container -- the base image uses a full absolute path for its ENTRYPOINT. We now run 'find' during the Docker build, write the path to /sitespeed_env, and source it in start.sh so SITESPEED_BIN is set before node app.js starts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
19
runner.js
19
runner.js
@@ -6,10 +6,6 @@ import { existsSync } from 'fs';
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const LOCAL_BIN = join(__dirname, '..', 'sitespeed.io', 'bin', 'sitespeed.js');
|
||||
|
||||
// Shell-escape a single argument (single-quote wrapping)
|
||||
function q(arg) {
|
||||
return `'${String(arg).replace(/'/g, "'\\''")}'`;
|
||||
}
|
||||
|
||||
export function runTest(job, onLine) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -40,12 +36,17 @@ export function runTest(job, onLine) {
|
||||
let child;
|
||||
|
||||
if (isDocker) {
|
||||
// In Docker, sitespeed.io is on PATH but execSync can't see it from Node's
|
||||
// limited environment. Use 'sh -c' so the full shell PATH is used.
|
||||
const shellCmd = ['sitespeed.io', ...sitespeedArgs].map(q).join(' ');
|
||||
onLine(`[runner] sh -c ${shellCmd.slice(0, 120)}...`);
|
||||
// SITESPEED_BIN is set by start.sh from the build-time path discovery
|
||||
const bin = process.env.SITESPEED_BIN;
|
||||
if (!bin) {
|
||||
return reject(new Error(
|
||||
'SITESPEED_BIN is not set. The Docker build may not have found sitespeed.js.\n' +
|
||||
'Check build logs for "Build-time sitespeed.js found at:"'
|
||||
));
|
||||
}
|
||||
onLine(`[runner] node ${bin}`);
|
||||
onLine(`[runner] DISPLAY=${env.DISPLAY}`);
|
||||
child = spawn('sh', ['-c', shellCmd], { cwd: __dirname, env });
|
||||
child = spawn('node', [bin, ...sitespeedArgs], { cwd: __dirname, env });
|
||||
} else {
|
||||
if (!existsSync(LOCAL_BIN)) {
|
||||
return reject(new Error(
|
||||
|
||||
Reference in New Issue
Block a user