feat: split image into shared aidc-base + thin per-project layer - #18
Open
ai-anant wants to merge 1 commit into
Open
feat: split image into shared aidc-base + thin per-project layer#18ai-anant wants to merge 1 commit into
ai-anant wants to merge 1 commit into
Conversation
Every project built the full ~3GB image (base OS + apt + uv/Python + all agents + all scanners) from scratch. Split the Dockerfile: - templates/devcontainer/Dockerfile.base.tmpl — the common layer; built once per content hash as aidc-base:<hash> and shared by every project on disk (Docker dedupes identical layers). - templates/devcontainer/Dockerfile.tmpl — now FROM aidc-base:<hash> and only adds toolchains, opt-in security tools, and the project setup hook. lib/aidc.sh: - aidc::ensure_base_image builds the base when the hashed tag is missing (called from up/rebuild/rescan/ensure_container_running before compose build); exports AIDC_BASE_IMAGE for the per-project FROM. - AIDC_BASE_IMAGE in project.env pins a custom base. - Dockerfile.base added to AIDC_MANAGED_PATHS + scaffolded by init. compose.yaml passes AIDC_BASE_IMAGE as a build arg. e2e asserts the new scaffold file. README documents the shared base. Verified: base (25 layers) + thin project (30 layers, 5 unique = toolchain delta) build end-to-end; project image reuses all base layers on disk. Refs cyfinoid#7
This was referenced Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every project was building the entire ~3 GB image from scratch: base OS + apt tools + uv/Python + all five coding agents + all scanners. Measured floor: 3.22 GB with zero toolchains. Ten projects = ~32 GB of images, ~30 GB of it identical content, and every new project paid a 10–20 minute build.
This PR splits the image into:
templates/devcontainer/Dockerfile.base.tmpl(new) — everything common: base OS, apt, uv/Python, agents, scanners, pmg wiring, clipboard bridge, bootstrap-claude. Built once per content hash asaidc-base:<hash>and shared by every project.templates/devcontainer/Dockerfile.tmpl— nowFROM aidc-base:<hash>and only adds the per-project toolchains, opt-in security tools, andproject-setup.sh.This is the "one copy of Python serves 10,000 sandboxes" idea from https://x.com/AlexJonesax/status/2083617647342600591 — projects boot from a shared, pre-verified base instead of rebuilding the world.
Changes
lib/aidc.shaidc::ensure_base_image— builds the hashed base image when missing, called fromcmd_up,cmd_rebuild,cmd_rescan, andensure_container_runningbefore the compose build; exportsAIDC_BASE_IMAGEso the project Dockerfile'sFROMresolves.aidc::base_image_tag— content hash ofDockerfile.base(+AIDC_AGENTSfor forward-compat with the opt-in agents PR), so template edits flow into a new tag automatically.AIDC_BASE_IMAGEin project.env pins a custom base..devcontainer/Dockerfile.baseadded toAIDC_MANAGED_PATHSand scaffolded byaidc init.templates/devcontainer/compose.yaml.tmpl— passesAIDC_BASE_IMAGEas a build arg..github/workflows/aidc-e2e.yml— asserts the new scaffold file.README.md— documents the shared base.Verification (measured)
aidc-base:4136caa40095, 25 layers) and the thin project image buildsFROMit (30 layers).bash -n,shellcheck -x, bash-3.2 compat,tests/resolve-oauth-token.test.sh(7/7) — clean.Expected impact
aidc upon a new project: builds only the toolchain delta (minutes, not tens of minutes).Merge note
Touches the same Dockerfile region as #15 (AIDC_AGENTS) — they compose cleanly (this PR already passes
AIDC_AGENTSthrough to the base build), but expect a trivial conflict on the agent block if both merge before rebasing.Closes #7