From 0f5897dde17899598535efee8dcc5f7192b0b118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Francoeur?= Date: Thu, 4 Jun 2026 19:00:16 +0400 Subject: [PATCH] update devcontainer - handle worktrees - update URLs --- .devcontainer/.gitignore | 1 + .devcontainer/devcontainer.json | 1 + .devcontainer/docker-compose.yml | 5 ++++- .devcontainer/init-env.sh | 23 +++++++++++++++++++++++ .devcontainer/squid.conf | 4 ++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/.gitignore create mode 100755 .devcontainer/init-env.sh diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore new file mode 100644 index 000000000..2eea525d8 --- /dev/null +++ b/.devcontainer/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ba4cd4632..01ac98901 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,6 +5,7 @@ "remoteUser": "node", "workspaceFolder": "/workspace", "waitFor": "postStartCommand", + "initializeCommand": ".devcontainer/init-env.sh", "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2b61b6248..225059b54 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -29,6 +29,8 @@ services: GO_VERSION: "1.24.10" RUST_VERSION: "1.88.0" PYTHON_VERSION: "3.11" + NVM_VERSION: "0.40.1" + NODE_VERSION: "22.13.0" environment: NODE_OPTIONS: "--max-old-space-size=4096" CLAUDE_CONFIG_DIR: "/home/node/.claude" @@ -40,8 +42,9 @@ services: networks: [sandbox] volumes: - ..:/workspace:delegated + # bind the main worktree, in case this is a linked worktree + - ${MAIN_GIT_DIR:?run .devcontainer/init-env.sh to generate .devcontainer/.env}:${MAIN_GIT_DIR}:delegated - claude-code-bashhistory:/commandhistory - - claude-code-config:/home/node/.claude cap_add: - NET_ADMIN diff --git a/.devcontainer/init-env.sh b/.devcontainer/init-env.sh new file mode 100755 index 000000000..b5bc1f2a9 --- /dev/null +++ b/.devcontainer/init-env.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +# Generates .devcontainer/.env so docker-compose can resolve MAIN_GIT_DIR. +# +# /workspace/.git inside the container is bind-mounted from the host. When the +# host workspace is a git worktree, .git is a pointer file containing +# gitdir: /.git/worktrees/ +# That absolute host path must exist verbatim inside the container, so we +# bind-mount the main repo's .git dir 1:1. +set -eu + +cd "$(dirname "$0")/.." + +if [ -f .git ]; then + gitdir=$(sed -n 's|^gitdir: ||p' .git) + main_git_dir=${gitdir%/worktrees/*} +elif [ -d .git ]; then + main_git_dir="$(pwd)/.git" +else + echo "init-env.sh: no .git found in $(pwd)" >&2 + exit 1 +fi + +printf 'MAIN_GIT_DIR=%s\n' "$main_git_dir" > .devcontainer/.env diff --git a/.devcontainer/squid.conf b/.devcontainer/squid.conf index 2f59cb626..bafba5955 100644 --- a/.devcontainer/squid.conf +++ b/.devcontainer/squid.conf @@ -10,11 +10,15 @@ acl allowed dstdomain \ .crates.io \ .static.rust-lang.org \ .npmjs.org \ + .nodejs.org \ .github.com \ .githubusercontent.com \ .go.dev \ .golang.org \ .anthropic.com \ + .claude.ai \ + .claude.com \ + .platform.claude.com \ .openai.com \ .sentry.io \ .statsig.com \