diff --git a/cli/src/commands/sandbox.ts b/cli/src/commands/sandbox.ts index fb5cd512..ff1e3c87 100644 --- a/cli/src/commands/sandbox.ts +++ b/cli/src/commands/sandbox.ts @@ -288,9 +288,9 @@ function prepare(opts: SandboxBuildOpts): PreparedBuild { } else { const copies = layer.tools .filter((tool) => tool.executablePath) - .map((tool) => `COPY tools/${tool.dir}/${tool.binary} /usr/local/bin/${tool.binary}`) + .map((tool) => `COPY --chmod=0755 tools/${tool.dir}/${tool.binary} /usr/local/bin/${tool.binary}`) .join("\n"); - dockerfileBody = `FROM ${base}\n${copies}\nRUN chmod -R a+rx /usr/local/bin\n${presenceCheck}`; + dockerfileBody = `FROM ${base}\n${copies}\n${presenceCheck}`; } const dockerfilePath = join(mkdtempSync(join(tmpdir(), "qm-sandbox-")), "Dockerfile"); writeFileSync(dockerfilePath, dockerfileBody); diff --git a/cli/test/e2e/sandbox-build.e2e.test.ts b/cli/test/e2e/sandbox-build.e2e.test.ts index b8874e72..cdaedcc8 100644 --- a/cli/test/e2e/sandbox-build.e2e.test.ts +++ b/cli/test/e2e/sandbox-build.e2e.test.ts @@ -17,7 +17,7 @@ test("sandbox build --dry-run generates the COPY-tools Dockerfile + the fly push assert.equal(r.code, 0, r.out); assert.match(r.out, /DRY RUN — nothing built/); assert.match(r.out, /FROM registry\.invalid\/qm\/qm-sandbox-base@sha256:a{64}/); - assert.match(r.out, /COPY tools\/example-tool\/example-tool \/usr\/local\/bin\/example-tool/); + assert.match(r.out, /COPY --chmod=0755 tools\/example-tool\/example-tool \/usr\/local\/bin\/example-tool/); assert.match(r.out, /command -v "\$b"/); assert.match(r.out, /docker buildx build --platform linux\/amd64 --load -t acme-sandbox:local/); } finally { diff --git a/cli/test/sandbox-build.test.ts b/cli/test/sandbox-build.test.ts index 75a052df..f138e8e5 100644 --- a/cli/test/sandbox-build.test.ts +++ b/cli/test/sandbox-build.test.ts @@ -56,7 +56,8 @@ test("generates a Dockerfile that COPYs each tool executable onto PATH + bakes t try { const out = dryRun({ sandboxDir: sb }); assert.match(out, /FROM registry\.invalid\/qm\/qm-sandbox-base@sha256:a{64}/); - assert.match(out, /COPY tools\/example-tool\/example-tool \/usr\/local\/bin\/example-tool/); + assert.match(out, /COPY --chmod=0755 tools\/example-tool\/example-tool \/usr\/local\/bin\/example-tool/); + assert.doesNotMatch(out, /chmod -R/); assert.match(out, /command -v "\$b"/); assert.match(out, /'example-tool'/); assert.match(out, /acme-sandbox:local/);