Skip to content

feat(devcontainer): add zero-build devcontainer from python_template - #49

Open
blooop wants to merge 3 commits into
mainfrom
feat/devcontainer
Open

blooop wants to merge 3 commits into
mainfrom
feat/devcontainer

Conversation

@blooop

@blooop blooop commented Aug 24, 2026 •

Copy link
Copy Markdown
Owner

template_rocker is a python_template descendant that predates the template having a
.devcontainer/, so until now it had none at all. This adds the template's
current one unchanged.

  • The config pulls ghcr.io/blooop/python_template/devcontainer:latest and
    builds nothing. Launching a branch is a pull, not a build.
  • It carries no docker feature. template_rocker's tests are pure unit tests -- argparse,
    snippet retrieval and unittest.mock -- so nothing here talks to a docker
    daemon and there is nothing for that feature to serve.
  • "name" sits at the end of the file. It is the only per-repo line, and keeping
    it away from the image block -- the block the template changes most -- is what
    keeps future pixi run update-from-template-repo merges from conflicting on
    it.

The tree is byte-identical to blooop/python_template#170 apart from that name.

Depends on blooop/python_template#170. The image it pulls is already published
and public, so this works before that merges.

dl blooop/template_rocker now gets a working pixi container.

🤖 Generated with Claude Code

Summary by Sourcery

Add a zero-build development container that pulls a shared Pixi-enabled image and provides integrated Claude Code tooling for repository work.

New Features:

  • Add a reusable Dev Container configuration with Pixi, Claude Code support, host credential integration, and repository setup automation.

Enhancements:

  • Provide a zero-build branch development environment based on a published GHCR image.
  • Document Claude Code authentication, configuration persistence, troubleshooting, and the security implications of sharing host credentials.

Build:

  • Add the CI container definition used to build the published development image, including the local Claude Code feature.

Deployment:

  • Configure branch containers to pull the published development image without rebuilding or applying per-branch features.

Documentation:

  • Add comprehensive usage, authentication, troubleshooting, and security documentation for the Claude Code Dev Container feature.

Chores:

  • Add container initialization and post-create setup for SSH host keys, Pixi environments, and optional repository tasks.

template_rocker is a python_template descendant that predates the template having a
.devcontainer/, so until now it had none at all. This adds the template's
current one unchanged.

- The config pulls ghcr.io/blooop/python_template/devcontainer:latest and
  builds nothing. Launching a branch is a pull, not a build.
- It carries no docker feature. template_rocker's tests are pure unit tests -- argparse,
  snippet retrieval and unittest.mock -- so nothing here talks to a docker
  daemon and there is nothing for that feature to serve.
- "name" sits at the end of the file. It is the only per-repo line, and keeping
  it away from the image block -- the block the template changes most -- is what
  keeps future `pixi run update-from-template-repo` merges from conflicting on
  it.

The tree is byte-identical to blooop/python_template#170 apart from that name.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @blooop, you have reached your weekly rate limit of 250000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces the current python_template devcontainer unchanged except for the repository name, with CI building and publishing the image while normal branch launches pull it directly for a zero-build pixi development environment.

Sequence diagram for pulling and launching the devcontainer

sequenceDiagram
    actor Developer
    participant Launcher as Devcontainer launcher
    participant Registry as GHCR registry
    participant Container as Pixi devcontainer
    participant Host as Host ~/.claude

    Developer->>Launcher: Launch branch
    Launcher->>Registry: Pull devcontainer:latest
    Registry-->>Launcher: Published image
    Launcher->>Host: Bind mount ~/.claude
    Launcher->>Container: Start with CLAUDE_CONFIG_DIR
    Container-->>Developer: Working pixi environment
Loading

File-Level Changes

Change Details Files
Add a zero-build devcontainer that pulls the published Python template image and keeps repository-specific configuration isolated.
  • Add a branch-launch configuration referencing the public GHCR image.
  • Avoid branch-time Docker builds, features, and Docker-daemon dependencies.
  • Place the repository-specific name field separately from the template-managed image block.
  • Mirror the upstream template devcontainer tree, including CI build configuration and local Claude Code feature assets.
.devcontainer/devcontainer.json
.devcontainer/ci/devcontainer.json
.devcontainer/Dockerfile
.devcontainer/claude-code/devcontainer-feature.json
.devcontainer/claude-code/install.sh
.devcontainer/claude-code/init-host.sh
.devcontainer/claude-code/README.md
.devcontainer/claude-code/TROUBLESHOOTING.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

The earlier commit on this branch removed the ~/.config/gh bind mount and
justified it with the claim that the mount never worked -- that `gh` keeps its
token in the system keyring, so the mounted hosts.yml carries no oauth_token.

That claim is false on this machine. ~/.config/gh/hosts.yml carries a real
oauth_token, and in a running container using that mount, with GH_TOKEN and
GITHUB_TOKEN unset, `gh auth status` reports:

    Logged in to github.com account blooop (/home/vscode/.config/gh/hosts.yml)

gh writes to a keyring only where one is available and falls back to the file
otherwise, so the keyring claim held for some environment but not this one, and
it got generalised into the config as if it always held.

Nothing broke under `dl`, which is why it went unnoticed: `dl` forwards
GH_TOKEN, devpod applies workspace env after the devcontainer's own, and the
env token wins wherever both are present. The entry paths that lost gh auth
they previously had are the non-`dl` ones -- a plain `devpod up`, and VS Code's
Reopen in Container. So the mount comes back.

The ~/.ssh removal is unaffected and stays removed. It was verified separately
in a live container: devpod forwards an ssh agent at a socket path of its own,
`ssh-add -l` lists the host key, and `git ls-remote` against a git@github.com:
origin succeeds with an empty ~/.ssh. The old hardcoded
SSH_AUTH_SOCK=/home/vscode/.ssh/agent.sock actively overrode that working
forwarded socket, so it stays gone too.
@blooop

blooop commented Aug 24, 2026

Copy link
Copy Markdown
Owner Author

Pushed a correction to this branch.

The earlier commit removed the ~/.config/gh bind mount on the grounds that it never worked -- that gh keeps its token in the system keyring, leaving the mounted hosts.yml without an oauth_token. That is false on this machine: hosts.yml carries a real oauth_token, and in a running container using the mount, with GH_TOKEN/GITHUB_TOKEN unset, gh auth status reports Logged in to github.com account blooop (/home/vscode/.config/gh/hosts.yml).

Nothing broke under dl because dl forwards GH_TOKEN and the env token wins. The entry paths that lost gh auth were the non-dl ones -- a plain devpod up and VS Code's Reopen in Container. So the mount is back.

The ~/.ssh removal is unaffected and stays removed: devpod forwards an ssh agent at its own socket path (verified live -- ssh-add -l lists the host key and git ls-remote succeeds with an empty ~/.ssh), and the old hardcoded SSH_AUTH_SOCK=/home/vscode/.ssh/agent.sock overrode that working socket.

…rek-install

Synced from blooop/python_template.

The previous postCreateCommand ended in `pixi run prek-install`. This repo does
not define that task, so `pixi run` exited 127, the lifecycle hook failed, and
container creation failed outright -- the workspace never came up. Found by
launching the container; neither JSON validation nor CI sees it.
postCreateCommand now calls .devcontainer/post-create.sh, which runs the task
only where it exists.

The script also seeds known_hosts. devpod forwards an ssh agent, so the host's
~/.ssh does not need mounting -- but the agent carries authentication, not host
identity, and on a fresh container the first git operation over an ssh remote
died with "Host key verification failed". Interactive users can click through
that; scripts, agents and in-container CI cannot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant