fix: harden Dockerfile templates — eliminate silent failures, use APT best practices#594
Conversation
|
@jerome-benoit is attempting to deploy a commit to the Matt Pocock's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the generated Dockerfile templates (and the repo’s own .sandcastle/Dockerfile) to avoid silent failures during GitHub CLI APT key/repo setup and to follow Debian/Docker APT best practices.
Changes:
- Reworked GitHub CLI installation steps to avoid
curl | dd/echo | tee, use/etc/apt/keyrings, and install with--no-install-recommends. - Added
--no-install-recommendsto base package installs across the agent Dockerfile templates and Beads tools. - Added a patch changeset documenting the behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/InitService.ts |
Updates Dockerfile template strings (APT install flags + hardened GitHub CLI setup) and adjusts some template text formatting. |
.sandcastle/Dockerfile |
Applies the same hardened GitHub CLI APT keyring/repo setup and --no-install-recommends to the dogfood image. |
.changeset/harden-dockerfile-templates.md |
Adds a patch changeset describing the Dockerfile hardening. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ARG AGENT_GID=1000 | ||
|
|
||
| # Rename the base image's "node" user to "agent" and align UID/GID. | ||
| # Rename the base image's \"node\" user to \"agent\" and align UID/GID. |
| ARG AGENT_GID=1000 | ||
|
|
||
| # Rename the base image's "node" user to "agent" and align UID/GID. | ||
| # Rename the base image's \"node\" user to \"agent\" and align UID/GID. |
| ARG AGENT_GID=1000 | ||
|
|
||
| # Rename the base image's "node" user to "agent" and align UID/GID. | ||
| # Rename the base image's \"node\" user to \"agent\" and align UID/GID. |
| ARG AGENT_GID=1000 | ||
|
|
||
| # Rename the base image's "node" user to "agent" and align UID/GID. | ||
| # Rename the base image's \"node\" user to \"agent\" and align UID/GID. |
| const GITHUB_CLI_TOOLS = `# GitHub CLI | ||
| RUN install -m 0755 -d /etc/apt/keyrings \\ | ||
| && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \\ | ||
| -o /etc/apt/keyrings/githubcli-archive-keyring.gpg \\ | ||
| && chmod a+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \\ | ||
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \\ | ||
| > /etc/apt/sources.list.d/github-cli.list \\ | ||
| && apt-get update && apt-get install -y --no-install-recommends gh \\ | ||
| && rm -rf /var/lib/apt/lists/*`; |
| # GitHub CLI | ||
| RUN install -m 0755 -d /etc/apt/keyrings \ | ||
| && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \ | ||
| -o /etc/apt/keyrings/githubcli-archive-keyring.gpg \ | ||
| && chmod a+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ | ||
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \ | ||
| > /etc/apt/sources.list.d/github-cli.list \ | ||
| && apt-get update && apt-get install -y --no-install-recommends gh \ |
|
Regarding the These are intentionally kept. The distinction:
If we want belt-and-suspenders here, |
… best practices - Replace curl|dd and echo|tee pipes with curl -o and > redirects - Migrate APT keyrings from /usr/share/keyrings/ to /etc/apt/keyrings/ - Add --no-install-recommends to all apt-get install calls - Apply same hardening to .sandcastle/Dockerfile (dogfood) Closes mattpocock#593
27e4639 to
b918ba1
Compare
Summary
Harden all Dockerfile templates to eliminate silent download failures and follow APT best practices.
Problem
The current
GITHUB_CLI_TOOLSconstant and all agent Dockerfile templates use pipe patterns that silently swallow failures:Solution
Changes
src/InitService.ts: HardenedGITHUB_CLI_TOOLSconstant (no pipes,/etc/apt/keyrings/,--no-install-recommends). Added--no-install-recommendsto base packages in all 4 agent Dockerfile templates +BEADS_TOOLS..sandcastle/Dockerfile: Same hardening applied to the repo's dogfood Dockerfile..changeset/harden-dockerfile-templates.md: Patch changeset.What this fixes for users
sandcastle initnow generates Dockerfiles that fail fast on network errors instead of building silently broken images--no-install-recommends/etc/apt/keyrings/location per Debian policyCloses #593