Files
vue-ts-example-2025/.devcontainer/devcontainer.json
严浩 a4e162cab0
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 1m34s
CI/CD Pipeline / build-and-deploy (push) Successful in 1m43s
测试最新依赖 / playwright (push) Successful in 1m49s
测试最新依赖 / build-and-test (push) Successful in 1m55s
build(devcontainer): configure pnpm cache and workspace settings
2025-11-13 23:14:49 +08:00

162 lines
7.1 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
*
* https://containers.dev/implementors/json_reference/#variables-in-devcontainerjson
* https://code.claude.com/docs/zh-CN/devcontainer
* https://github.com/Kilo-Org/kilocode/blob/main/cli/Dockerfile
*/
{
"name": "SBX",
"image": "my-dev-container",
// "build": { "dockerfile": "Dockerfile", "args": {} },
"runArgs": [
// -----
// "--network=host",
// "--add-host=myservice.local:127.0.0.1",
// -----
// "--env-file",
// ".devcontainer/.env",
// -----
"--cap-add=NET_ADMIN",
"--cap-add=NET_RAW",
"--add-host=host.docker.internal:host-gateway",
"--name=${localWorkspaceFolderBasename}-devcontainer"
],
"forwardPorts": [4730, 4731], // vscode://settings/remote.localPortHost -> 默认只监听 localhost
"portsAttributes": {
"4730": { "label": "开发服务器端口", "onAutoForward": "notify" },
"4731": { "label": "预览服务器端口", "onAutoForward": "notify" }
},
"customizations": {
"vscode": {
"extensions": [
// AI
"github.copilot-chat",
"vicanent.gcmp",
"anthropic.claude-code",
"google.gemini-cli-vscode-ide-companion",
"kilocode.kilo-code",
"alibaba-cloud.tongyi-lingma",
// >>>>>
// "eamodio.gitlens",
"tu6ge.naive-ui-intelligence",
"gruntfuggly.todo-tree",
"lokalise.i18n-ally",
"vitest.explorer",
"antfu.unocss",
"vue.volar",
// <<<<<
// 代码质量 / 格式化 / Lint
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint",
"oxc.oxc-vscode",
"esbenp.prettier-vscode"
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"chat.extensionUnification.enabled": true,
"chat.tools.terminal.autoApprove": { "/.*/": true },
"chat.tools.terminal.ignoreDefaultAutoApproveRules": false,
// * 尽管使用了“/.*/”,但有些还是会失败,因为有几个错误的默认值:
// * https://github.com/microsoft/vscode/issues/266651#issuecomment-3292581459
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "dev",
"label": "🚀 Dev: Run on Folder Open",
"detail": "启动开发服务器",
"runOptions": { "runOn": "folderOpen" },
"problemMatcher": [],
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated" },
"group": { "kind": "build", "isDefault": false }
}
]
},
"terminal.integrated.defaultProfile.linux": "💲zsh",
"terminal.integrated.profiles.linux": {
"💲zsh": {
"path": "zsh",
"icon": "terminal-cmd",
"overrideName": true,
"color": "terminal.ansiGreen"
}
},
// https://stackoverflow.com/questions/75708866/vscode-dev-container-fails-to-load-ms-vscode-js-debug-extension-correctly
// https://davidwesst.com/blog/missing-bootloader-in-vscode-devcontainer/
/**
* autoAttachFilter NODE_OPTIONS bootloader.js --require
* --max-old-space-size
* NODE_OPTIONS= --require /home/.../bootloader.js --max-old-space-size=4096--max-old-space-size=4096
*
* Error: illegal value for flag --max-old-space-size=4096--max-old-space-size=4096 of type size_t
* "disabled"
*/
"debug.javascript.autoAttachFilter": "disabled"
}
}
},
"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}",
"NODE_OPTIONS": "--max-old-space-size=4096",
"CLAUDE_CONFIG_DIR": "/home/usr_vscode/.claude",
"DEVCONTAINER": "true", // https://github.com/anthropics/claude-code/blob/1fe9e369a7c30805189cbbb72eb69c15ed4ec96b/.devcontainer/Dockerfile#L42
"SANDBOX": "sandbox-devcontainer", // gemini 显示这个。
"TZ": "${localEnv:TZ:Asia/Shanghai}"
},
"mounts": [
"source=${localWorkspaceFolderBasename}---bashhistory,target=/commandhistory,type=volume",
"source=${localWorkspaceFolderBasename}---iflow,target=/home/usr_vscode/.iflow,type=volume",
"source=${localWorkspaceFolderBasename}---gemini,target=/home/usr_vscode/.gemini,type=volume",
"source=${localWorkspaceFolderBasename}---claude-code-router,target=/home/usr_vscode/.claude-code-router,type=volume",
"source=${localWorkspaceFolderBasename}---claude-code,target=/home/usr_vscode/.claude,type=volume",
"source=${localWorkspaceFolderBasename}---pnpm-store,target=/home/usr_vscode/.pnpm-store,type=volume",
"source=${localWorkspaceFolderBasename}---cache-pnpm,target=/home/usr_vscode/.cache/pnpm,type=volume",
"source=${localWorkspaceFolderBasename}---node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
],
/**
*
1. initializeCommand ()
2.
3. onCreateCommand ()
4. updateContentCommand ()
5. postCreateCommand ()
6.
7. postStartCommand ()
8. VS Code
9. postAttachCommand ()
*/
"initializeCommand": /* */ "echo '准备创建容器...'",
"onCreateCommand": /* */ {
"setup-node": "pnpm env use lts --global",
"fix-claude-code-router": "sudo chown -R usr_vscode /home/usr_vscode/.claude-code-router",
"fix-claude": "sudo chown -R usr_vscode /home/usr_vscode/.claude",
"fix-gemini": "sudo chown -R usr_vscode /home/usr_vscode/.gemini",
"fix-iflow": "sudo chown -R usr_vscode /home/usr_vscode/.iflow",
"fix-node_modules": "sudo chown usr_vscode node_modules"
},
"updateContentCommand": /* */ "pnpm install",
"postCreateCommand": /* */ {
"install-global-cli": "pnpm install -g @google/gemini-cli@latest @anthropic-ai/claude-code@latest @musistudio/claude-code-router@latest @iflow-ai/iflow-cli@latest"
},
"postStartCommand": /* */ "echo '容器已启动!'",
"postAttachCommand": /* */ "echo '开发环境已就绪!${containerWorkspaceFolder}'",
// "updateRemoteUserUID": true,
"waitFor": "updateContentCommand",
// "workspaceMount": "source=${localWorkspaceFolder},target=/${localWorkspaceFolderBasename},type=bind,consistency=delegated",
// "workspaceFolder": "/${localWorkspaceFolderBasename}",
"remoteUser": "usr_vscode"
}