From d5c7a19e97668d5a4ba77e16287ef942b4645ed5 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Mon, 24 Aug 2026 19:34:33 +0100 Subject: [PATCH 1/2] fix(devcontainer): move name to the end so template merges stop conflicting "name" was line 2, sitting directly on top of the build block. It is the only per-repo value in this file, so it is the only line we ever edit here -- and it happens to sit next to the block that churns most upstream. git cannot split adjacent hunks, so every `pixi run update-from-template-repo` came back with a conflict on this one file. Measured on blooop/dbw: reverting only the name line made the same merge run clean. Moving the name to the end of the object turns the two edits into two separate hunks, and they merge without help. Also fixes the value. It read "python_template", which names a different project entirely; pyproject.toml has said "rockerc" all along. That is the signature of a past template merge resolving this exact conflict the wrong way -- taking the template's side of the name line. Now set to "rockerc". Deliberately unchanged in this repo: - the Dockerfile - "features": docker-in-docker:2, which this repo needs and the shared template image does not provide. This repo is not being synced to python_template's image. --- .devcontainer/devcontainer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b886722..7640237 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,4 @@ { - "name": "python_template", "build": { "dockerfile": "Dockerfile", "context": "..", @@ -23,5 +22,8 @@ "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, "mounts": ["source=${localWorkspaceFolderBasename}-pixi,target=${containerWorkspaceFolder}/.pixi,type=volume"], - "postCreateCommand": "sudo chown vscode .pixi && pixi install" + "postCreateCommand": "sudo chown vscode .pixi && pixi install", + // "name" lives at the end on purpose: it is the only line this repo + // changes, and next to the build block every template merge conflicts. + "name": "rockerc" } From 423e31db94c31991347c2eb33a03f37c378b836d Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Mon, 24 Aug 2026 22:13:24 +0100 Subject: [PATCH 2/2] fix(devcontainer): move postCreate into a script, and seed known_hosts Synced from blooop/python_template. postCreateCommand now calls .devcontainer/post-create.sh. The script runs `pixi run ` only where the task is actually defined, and seeds known_hosts with ssh-keyscan for whatever host origin points at. 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. --- .devcontainer/devcontainer.json | 2 +- .devcontainer/post-create.sh | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 .devcontainer/post-create.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7640237..0f5ad88 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,7 +22,7 @@ "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, "mounts": ["source=${localWorkspaceFolderBasename}-pixi,target=${containerWorkspaceFolder}/.pixi,type=volume"], - "postCreateCommand": "sudo chown vscode .pixi && pixi install", + "postCreateCommand": ".devcontainer/post-create.sh", // "name" lives at the end on purpose: it is the only line this repo // changes, and next to the build block every template merge conflicts. "name": "rockerc" diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 0000000..fc32480 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# postCreateCommand for this repo and every repo cut from this template. +# +# It lives in a script rather than inline in devcontainer.json for two reasons: +# the steps below have to differ per repo (not every descendant defines every +# pixi task), and a one-line string in the JSON is a permanent merge-conflict +# surface for children pulling template updates. +set -euo pipefail + +# 1. The .pixi volume is created by docker, owned by root. +sudo chown vscode .pixi + +# 2. Seed known_hosts for the forge this clone actually uses. +# +# devpod forwards an ssh agent, so auth works without the host's ~/.ssh being +# mounted -- but host identity does not come with it. Without a known_hosts +# entry the first git operation over an ssh remote fails with "Host key +# verification failed": an interactive user gets a yes/no prompt, anything +# non-interactive (a script, an agent, CI in the container) just dies. +host=$(git config --get remote.origin.url 2>/dev/null | + sed -nE 's#^(ssh://)?git@([^:/]+).*#\2#p') || true +if [ -n "${host:-}" ]; then + mkdir -p ~/.ssh && chmod 700 ~/.ssh + touch ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts + if ! ssh-keygen -F "$host" >/dev/null 2>&1; then + if scanned=$(ssh-keyscan -T 10 -t rsa,ecdsa,ed25519 "$host" 2>/dev/null) && + [ -n "$scanned" ]; then + printf '%s\n' "$scanned" >> ~/.ssh/known_hosts + sort -u -o ~/.ssh/known_hosts ~/.ssh/known_hosts + echo "post-create: seeded known_hosts for $host" + else + # Non-fatal: no network at postCreate must not fail container creation. + echo "post-create: could not reach $host, skipping known_hosts" >&2 + fi + fi +fi + +# 3. The environment itself. +pixi install + +# 4. Optional tasks. A descendant that does not define one simply skips it -- +# hardcoding `pixi run prek-install` here fails container creation outright with +# exit 127 on every repo that lacks the task, which is most of them. +# `pixi task list` prints to stderr, not stdout -- redirecting it to /dev/null +# silently yields an empty list and skips tasks the repo really does define. +tasks=$(pixi task list --summary 2>&1 | tr ' ,' '\n\n' || true) +for task in prek-install; do + if grep -qx "$task" <<<"$tasks"; then + echo "post-create: running '$task'" + pixi run "$task" + else + echo "post-create: no '$task' task in this repo, skipping" + fi +done