Files
vue-ts-example-2025/.devcontainer/devcontainer.json
严浩 aa55508ed7
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 2m11s
CI/CD Pipeline / build-and-deploy (push) Successful in 3m13s
feat: 更新 Dockerfile 和 devcontainer.json,添加别名和配置目录
2025-11-07 11:44:59 +00:00

103 lines
4.0 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
*/
{
"name": "Sandbox Dev Container",
"forwardPorts": [4730, 4731], // vscode://settings/remote.localPortHost -> 默认只监听 localhost
"portsAttributes": {
"4730": { "label": "开发服务器端口", "onAutoForward": "notify" },
"4731": { "label": "预览服务器端口", "onAutoForward": "notify" }
},
"build": {
"dockerfile": "Dockerfile",
"args": {
"TZ": "${localEnv:TZ:Asia/Shanghai}"
}
},
"runArgs": [
// -----
// "--network=host",
// "--add-host=myservice.local:127.0.0.1",
// -----
// "--env-file",
// ".devcontainer/.env",
// -----
"--cap-add=NET_ADMIN",
"--cap-add=NET_RAW"
],
"customizations": {
"vscode": {
"extensions": [
// AI
"anthropic.claude-code",
"google.gemini-cli-vscode-ide-companion",
"kilocode.kilo-code",
"alibaba-cloud.tongyi-lingma",
// >>>>>
"vue.volar",
"lokalise.i18n-ally",
"eamodio.gitlens",
"vitest.explorer",
// <<<<<
// 代码质量 / 格式化 / 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"
},
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"bash": { "path": "bash", "icon": "terminal-bash" },
"zsh": { "path": "zsh", "icon": "terminal-debian" }
},
// 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}",
"CLAUDE_CONFIG_DIR": "/home/usr_vscode/.claude",
"NODE_OPTIONS": "--max-old-space-size=4096"
},
"remoteUser": "usr_vscode",
"mounts": [
"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; echo '${localWorkspaceFolderBasename}'", // 每次容器启动时执行
// "postAttachCommand": "pnpm config get store-dir", // 连接到容器后执行
// "updateRemoteUserUID": true,
"waitFor": "postStartCommand",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=delegated",
"workspaceFolder": "/workspace"
}