Pre-cache devcontainer image on GHCR for faster Coder startup#31
Merged
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Avoids misleading 'DRY_RUN:' prefix on live runs and covers ENVBUILDER_IMAGE / ENVBUILDER_CACHE_TTL_DAYS override paths. Co-authored-by: Copilot <[email protected]>
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.
Why
Coder builds this devcontainer with envbuilder, which rebuilds the whole image (Dockerfile and every feature — Go, Ruby, Rust, kubectl/helm/minikube, Azure CLI, Playwright, …) on every workspace start. This adds a GitHub Action that pre-builds and pushes a fully cached image to GHCR, so Coder reuses the cache instead of rebuilding (envbuilder's docs cite ~36m → ~40s).
What
scripts/build-cache.sh(+build-cache_test.sh): runs the same envbuilder Coder uses withENVBUILDER_CACHE_REPO+ENVBUILDER_PUSH_IMAGE=1, pushing every layer and a complete prebuilt image toghcr.io/bmorton/devcontainer-cache. Reusesscripts/verify-devcontainer.shas the init script so a broken/scheduled regression fails loudly. Credentials are passed to docker via env inheritance (never argv or$GITHUB_ENV)..github/workflows/cache-devcontainer.yml: triggers on push→main, weekly (0 6 * * 1), andworkflow_dispatch.permissions: contents:read + packages:write, runnernamespace-profile-devcontainer.README.md: documents the cache, the one-time "make package public" step, and accurate Coder consumption.Key constraint
envbuilder is pinned to
ghcr.io/coder/envbuilder:1.3.0and must match the version Coder runs, or layer-cache hashes won't match.Out-of-band steps (can't be automated here)
devcontainer-cacheGHCR package visibility to Public.ENVBUILDER_CACHE_REPO=ghcr.io/bmorton/devcontainer-cacheto reuse cached layers, orenvbuilder_cached_imageresource to boot directly from the prebuilt image.Notes
Docker isn't available in the authoring devcontainer, so the script is validated via its
DRY_RUNpath (14/14 tests pass). The real build+push only runs on CI. Design spec and implementation plan included underdocs/superpowers/.Co-authored-by: Copilot [email protected]