feat(dev): add devcontainers#9187
Draft
keturn wants to merge 4 commits into
Draft
Conversation
Contributor
Author
|
This is a viable proof of concept. Floating it here as a draft to see if it seems more palatable than last year's attempt. If there's appetite for it, I can update the contributor/developer docs to incorporate it. And hopefully we find people to work out how things go on a wider range of hosts (Windows, Mac, ROCm, etc). |
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
Development Containers can be a good way to get a development environment running. Containers also provide some isolation to the host system from supply chain attacks (though this is not absolute; your IDE will still require you to assert you trust this repository before it will run this configuration).
Dev containers may be run locally by your IDE (VS Code, PyCharm Pro), on a cloud IDE (GitHub Codespaces), or by an editor-agnostic host (DevPod).
Implementation Details
Unfortunately there is no extension mechanism for
devcontainer.json, so we've cobbled one together.base/partial.jsonccontains the common base of the devcontainer configuration.merge-partial-configs.shmerges it with otherpartial.jsoncfiles to form fulldevcontainer.jsonconfigs in subdirectories.Differences from /docker/Dockerfile
Production containers are typically optimized for deployment size and strip away anything non-essential for running their single service.
Development containers are built for developer experience. They include all the tools to build, test, and debug the application.
Production containers include the application code in their image.
Development containers assume you're going to be changing the code,
so the image provides the environment but the application code is mounted separately at runtime.
Related Issues / Discussions
It's been a year since the last time we tried this in #7944. Since then, Invoke's pyproject.toml has gotten better-behaved about compatibility with
uv syncin how it manages the torch dependencies.I did this one pretty much from scratch and ended up with some different results for where package caches live than @dsisco11's version. I'm not attached to those differences, and we could certainly bring those configurations forward to here if it seems like a good idea on review.
QA Instructions
Open the project in VS Code and run its Reopen in Container command.
For each, the
installstep for all packages should automatically happen when the container is started, leaving development commands ready to run.docs/, runpnpm run buildinvokeai/frontend/web/, runpnpm run buildinvokeai-weband make sure it has appropriate GPU access, and that your browser can load it.If you're feeling ambitious, do all of the above in PyCharm/WebStorm Pro, DevPod, and your other favorite IDE.
Merge Plan
This PR is currently self-contained to the
.devcontainerdirectory and thus has minimal merge considerations.Checklist
N/AChanges to a redux slice have a corresponding migrationWhat's Newcopy (if doing a release after this PR)