fix: resolve Docker bind mount permission errors on Linux

Use entrypoint-based UID remapping instead of --user flag so the
container's pentest user matches the host UID/GID, keeping bind-mounted
volumes writable. Git config moved to --system level to survive remapping.
This commit is contained in:
ezl-keygraph
2026-03-16 17:09:54 +05:30
parent d89dbcd58b
commit de8b7c368d
4 changed files with 36 additions and 10 deletions
+2 -1
View File
@@ -3,6 +3,7 @@
*/
import { execFileSync } from 'node:child_process';
import os from 'node:os';
import { getWorkerImage } from '../docker.js';
import { getWorkspacesDir } from '../home.js';
@@ -24,7 +25,7 @@ export function workspaces(version: string): void {
'node',
'apps/worker/dist/temporal/workspaces.js',
],
{ stdio: 'inherit' },
{ stdio: 'inherit', ...(os.platform() === 'win32' && { env: { ...process.env, MSYS_NO_PATHCONV: '1' } }) },
);
} catch {
console.error('ERROR: Failed to list workspaces. Is the Docker image available?');
+7 -1
View File
@@ -207,6 +207,11 @@ export function spawnWorker(opts: WorkerOptions): ChildProcess {
// Add host flag for Linux
args.push(...addHostFlag());
// UID remapping for Linux bind mounts
if (os.platform() === 'linux' && process.getuid && process.getgid) {
args.push('-e', `SHANNON_HOST_UID=${process.getuid()}`, '-e', `SHANNON_HOST_GID=${process.getgid()}`);
}
// Volume mounts
args.push('-v', `${opts.workspacesDir}:/app/workspaces`);
args.push('-v', `${opts.repo.hostPath}:${opts.repo.containerPath}`);
@@ -257,7 +262,8 @@ export function spawnWorker(opts: WorkerOptions): ChildProcess {
args.push('--pipeline-testing');
}
return spawn('docker', args, { stdio: 'pipe' });
// Prevent MSYS/Git Bash from converting Unix paths (e.g. /repos/my-repo) to Windows paths
return spawn('docker', args, { stdio: 'pipe', ...(os.platform() === 'win32' && { env: { ...process.env, MSYS_NO_PATHCONV: '1' } }) });
}
/**