Conversation
Line 65 ends with backslash + trailing space. The backslash escapes the space, so the shell sees an unescaped newline: every command from 'alias vim' onward (vim/diff/pip aliases, venv activation, cd pufferlib, mesa env) was a syntax error and never made it into the image.
Apply the fastdocker principles (eblog.fly.dev/fastdocker.html): - Cache mounts for apt lists/debs, the uv wheel cache (~3GB torch wheels download once), ccache, and the experiments.zip baseline download. - Layer ordering least-to-most-frequently-changed; the init.vim and entrypoint.sh COPYs move to the end so config edits no longer invalidate the nsight/torch/pufferlib layers. - ARG NEOVIM_REF/PUFFERLIB_REF/PUFFERAI_REF so clone layers can be refreshed via --build-arg without editing the file (defaults unchanged: master/4.0/4.0). - Neovim builds in a separate stage with CMAKE_INSTALL_PREFIX=/opt/nvim; the final image keeps only the installed runtime, dropping the source tree, build artifacts, and cmake/ninja/gettext/unzip. Adds -j(nproc). - Merge scattered apt installs into one update+install layer; nsight stays on its own layer; COPY --chmod=755 replaces COPY+chmod; drop the no-op trailing 'apt-get clean' layer. - .dockerignore whitelists the two COPY'd files: context drops from the whole repo to 274 bytes.
…lder, unzip in final stage
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.
Fast Docker build: cache mounts, layer ordering, multi-stage Neovim (+1 bug fix)
Applies the principles from eblog's FastDocker to
puffertank.dockerfile.Changes
Cache mounts (BuildKit) —
--mount=type=cacheso rebuilds reuse state across builds:/root/.cache/uv→ the ~3GB of cu130 torch wheels download once, not on every layer invalidation/root/.cache/puffer→experiments.zipbaseline download survives rebuilds/var/cache/apt+/var/lib/apt→ package lists/debs shared across builds/root/.ccache(was already present)Layer ordering: least → most frequently changed
COPY init.vim(was line 29) andCOPY entrypoint.sh(was line 59) moved to the end. Previously, editing your vimrc invalidated the nsight, torch, and pufferlib layers — a multi-GB re-download per config tweak. Now a vimrc edit rebuilds only the final COPY layers.ARG NEOVIM_REF/PUFFERLIB_REF/PUFFERAI_REFlet you refresh git-clone layers with--build-arginstead of editing the file (Docker cachesgit clonelayers forever since it never re-checks the remote). Defaults unchanged:master/4.0/4.0.Multi-stage build (ship the pizza, not the oven)
nvim-builderstage withCMAKE_INSTALL_PREFIX=/opt/nvim; the final image copies only the installed runtime. Drops the nvim source tree + build artifacts and cmake/ninja/gettext/unzip from the final image.make -j$(nproc)parallelizes the compile.Smaller, granular layers
apt-get installRUNs merged into oneupdate && installlayer (same package list); nsight stays on its own layer since it's large and version-bumped independently.COPY --chmod=755replaces the COPY+chmod pair.RUN apt-get clean— a cleanup in a new layer never shrinks the layers below it..dockerignore — rewritten as a whitelist: build context drops from ~15KB of repo noise to the 2 files the image COPYs (4.10kB measured at build-time context transfer), and the broken
puffertank -> /puffertanksymlink is excluded. Hygiene win, not a speed win.Follow-up package fixes (review feedback) — the builder stage now installs
git ca-certificates build-essential(it runsgit clone+make), and the final stage keepsunzip(the puffer layer runsunzip -q). Without these both stages fail.Bug fix (separate commit)
Line 65 ends with
\␣(backslash + trailing space). The backslash escapes the space, leaving an unescaped newline: a syntax error at&& echo …(sh -nexits 2 on the original, 0 on the fix). The whole RUN layer — and therefore any build from this revision — fails; nothing fromalias vimonward ever lands. Continuations normalized; all 7 payloads byte-identical.Validation (measured on amd64, 24-core, docker buildx 0.36.1)
Baseline is
4.0+ the 1-char bashrc fix (pure4.0cannot build, per above). All four builds exit 0;docker buildx build --checkpasses with no warnings on both Dockerfiles.--no-cachebuildinit.vimeditFunctional smoke test of the built image:
nvim --version→ v0.13.0-dev, thevim/diff/pipbashrc aliases all present, pufferlib checkout builds.