perf: optimize devcontainer lifecycle (~17-25s faster startup)#149
perf: optimize devcontainer lifecycle (~17-25s faster startup)#149
Conversation
merge=ours in .gitattributes is not a built-in git merge driver—it needs an explicit driver definition. Without it, git falls back to the text driver and reports conflicts on pixi.lock. Add `git config merge.ours.driver true` to devcontainer postCreateCommand so the driver is configured on container creation.
Pre-install dotfiles pixi global packages and pre-warm project deps in the Docker image so runtime installs are near-instant. - Bake devpod-profile pixi global tools into Dockerfile (saves ~14.7s) - Pre-warm project .pixi env for cold starts (saves ~8.3s) - Comment out claude-code feature in prebuilt mode (saves ~2s) - Remove redundant sudo chown from postCreateCommand - Add pyproject.toml/pixi.lock to CI rebuild triggers
Reviewer's GuideOptimizes devcontainer startup by baking pixi global tools and a pre-warmed project environment into the image, wiring CI to rebuild when dependency manifests change, and adding a static manifest for devpod global tools. Sequence diagram for optimized devcontainer cold start with prewarmed pixi envsequenceDiagram
actor Developer
participant DevpodCLI
participant DockerDaemon
participant DevcontainerRuntime as Devcontainer
participant Pixi
Developer->>DevpodCLI: devpod up . --ide none
DevpodCLI->>DockerDaemon: Pull prebuilt devcontainer image
DockerDaemon-->>DevpodCLI: Image with pixi globals + prewarmed env
DevpodCLI->>DockerDaemon: Start container
DockerDaemon-->>DevcontainerRuntime: Run onCreateCommand
DevcontainerRuntime->>DevcontainerRuntime: Copy /home/vscode/.pixi-prewarm to volume .pixi
DevcontainerRuntime->>Pixi: Initialize project env from prewarmed .pixi
Pixi-->>DevcontainerRuntime: Project deps ready (no full pixi install)
DevcontainerRuntime->>Pixi: Check pixi global envs
Pixi-->>DevcontainerRuntime: Global tools already installed
DevcontainerRuntime-->>Developer: Shell ready with tools and deps
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In the Dockerfile, consider explicitly creating
/home/vscode/.pixi/manifestsbefore theCOPY+pixi global syncstep so the build doesn’t depend on that directory being created elsewhere or in a specific base image version. - The
COPY pyproject.toml pixi.lock /tmp/pixi-prewarm/step will fail ifpixi.lockis absent; if that file is optional, you may want to either generate it earlier in the build or make the copy more robust (e.g. copy onlypyproject.tomland letpixi installcreate the lock). - The pre-warm step hardcodes a
python_templatepackage directory; if the project name changes, this will silently diverge, so it might be better to derive the directory name from a single source of truth (e.g. an ARG or existing project path) rather than embedding it in the Dockerfile.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the Dockerfile, consider explicitly creating `/home/vscode/.pixi/manifests` before the `COPY` + `pixi global sync` step so the build doesn’t depend on that directory being created elsewhere or in a specific base image version.
- The `COPY pyproject.toml pixi.lock /tmp/pixi-prewarm/` step will fail if `pixi.lock` is absent; if that file is optional, you may want to either generate it earlier in the build or make the copy more robust (e.g. copy only `pyproject.toml` and let `pixi install` create the lock).
- The pre-warm step hardcodes a `python_template` package directory; if the project name changes, this will silently diverge, so it might be better to derive the directory name from a single source of truth (e.g. an ARG or existing project path) rather than embedding it in the Dockerfile.
## Individual Comments
### Comment 1
<location path=".devcontainer/Dockerfile" line_range="31-35" />
<code_context>
+
+# Pre-warm project pixi environment for faster cold starts
+COPY --chown=vscode pyproject.toml pixi.lock /tmp/pixi-prewarm/
+RUN mkdir -p /tmp/pixi-prewarm/python_template \
+ && touch /tmp/pixi-prewarm/python_template/__init__.py \
+ && cd /tmp/pixi-prewarm \
+ && pixi install \
+ && mv .pixi /home/vscode/.pixi-prewarm
</code_context>
<issue_to_address>
**suggestion (performance):** Consider cleaning up the temporary /tmp/pixi-prewarm directory to avoid bloating the image
Since `/tmp/pixi-prewarm` and the `python_template` placeholder are only needed during build to bootstrap pixi, everything there becomes unused once `.pixi` is moved to `/home/vscode/.pixi-prewarm`. Consider appending `&& rm -rf /tmp/pixi-prewarm` to this `RUN` command to avoid shipping that dead weight in the final image layer.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| RUN mkdir -p /tmp/pixi-prewarm/python_template \ | ||
| && touch /tmp/pixi-prewarm/python_template/__init__.py \ | ||
| && cd /tmp/pixi-prewarm \ | ||
| && pixi install \ | ||
| && mv .pixi /home/vscode/.pixi-prewarm |
There was a problem hiding this comment.
suggestion (performance): Consider cleaning up the temporary /tmp/pixi-prewarm directory to avoid bloating the image
Since /tmp/pixi-prewarm and the python_template placeholder are only needed during build to bootstrap pixi, everything there becomes unused once .pixi is moved to /home/vscode/.pixi-prewarm. Consider appending && rm -rf /tmp/pixi-prewarm to this RUN command to avoid shipping that dead weight in the final image layer.
Summary
install.sh'spixi global syncis a no-op (~14.7s saved).pixienvironment — runspixi installduring image build and copies the result into the volume on cold starts viaonCreateCommand(~8.3s saved)sudo chown vscode .pixifrompostCreateCommandpyproject.toml/pixi.lockto CI rebuild triggers so the pre-warmed deps stay freshNew file:
.devcontainer/pixi-global-devpod.tomlStatic manifest rendered from the chezmoi template's devpod profile. Keep in sync with
dot_pixi/manifests/pixi-global.toml.tmplwhen adding/removing dotfiles tools.Expected results
--recreate)Toggle scripts
Verified
devcontainer_use_local.sh/devcontainer_use_prebuilt.shround-trip correctly with the new commented features block.Test plan
devpod delete pythontemplate && docker volume rm python_template-pixithentime devpod up . --ide none(cold start)time devpod up . --ide none --recreate(warm start)pixi run python --version && claude --versionpixi run dev-use-localthenpixi run dev-use-prebuiltround-trip🤖 Generated with Claude Code
Summary by Sourcery
Optimize devcontainer startup performance by pre-baking pixi environments and tooling into the image and tightening rebuild triggers.
Enhancements:
Build:
CI: