From aa55508ed75096d97efeb7a9f83ebdfba62e3085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Fri, 7 Nov 2025 11:44:59 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20Dockerfile=20?= =?UTF-8?q?=E5=92=8C=20devcontainer.json=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=AB=E5=90=8D=E5=92=8C=E9=85=8D=E7=BD=AE=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 3 ++- .devcontainer/devcontainer.json | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d5777f5..4bba1bc 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -77,7 +77,8 @@ RUN touch /home/usr_vscode/.zshrc \ -p fzf \ -a "source <(fzf --zsh)" \ -a "export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ - -x + -x \ + && echo "alias claude='claude --dangerously-skip-permissions'" >> /home/usr_vscode/.zshrc # -a "source /usr/share/doc/fzf/examples/key-bindings.zsh" \ # -a "source /usr/share/doc/fzf/examples/completion.zsh" \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f28680b..d3e3372 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,9 @@ +/** + * 一些参考链接: + * https://containers.dev/implementors/json_reference/#variables-in-devcontainerjson + * https://code.claude.com/docs/zh-CN/devcontainer + */ + { "name": "Sandbox Dev Container", "forwardPorts": [4730, 4731], // vscode://settings/remote.localPortHost -> 默认只监听 localhost @@ -71,25 +77,26 @@ } } }, - "containerEnv": { // "CLAUDE_CONFIG_DIR": "/home/usr_vscode/.claude", "ANTHROPIC_AUTH_TOKEN": "${localEnv:ANTHROPIC_AUTH_TOKEN}", "ANTHROPIC_BASE_URL": "${localEnv:ANTHROPIC_BASE_URL}", "GEMINI_API_KEY": "${localEnv:GEMINI_API_KEY}", "GOOGLE_GEMINI_BASE_URL": "${localEnv:GOOGLE_GEMINI_BASE_URL}", + "CLAUDE_CONFIG_DIR": "/home/usr_vscode/.claude", "NODE_OPTIONS": "--max-old-space-size=4096" }, "remoteUser": "usr_vscode", "mounts": [ - // "source=dev-container-bashhistory-${devcontainerId},target=/commandhistory,type=volume" + "source=${localWorkspaceFolderBasename}-bashhistory,target=/commandhistory,type=volume", + "source=${localWorkspaceFolderBasename}-claude-code-config,target=/home/usr_vscode/.claude,type=volume", "source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume" ], "postCreateCommand": "sudo chown usr_vscode node_modules", // 容器创建后执行 https://code.visualstudio.com/remote/advancedcontainers/improve-performance - "postStartCommand": "pnpm -v", // 每次容器启动时执行 + "postStartCommand": "pnpm -v; echo '${localWorkspaceFolderBasename}'", // 每次容器启动时执行 // "postAttachCommand": "pnpm config get store-dir", // 连接到容器后执行 // "updateRemoteUserUID": true, - // "waitFor": "postStartCommand" + "waitFor": "postStartCommand", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=delegated", "workspaceFolder": "/workspace" }