143 lines
5.5 KiB
JSON
143 lines
5.5 KiB
JSON
{
|
||
"image": "ghcr.io/yanhao98/h-devcontainer:main",
|
||
"runArgs": ["--name=${localWorkspaceFolderBasename}-devcontainer"],
|
||
"forwardPorts": [4730, 4731], // vscode://settings/remote.localPortHost -> 默认只监听 localhost
|
||
"portsAttributes": {
|
||
"4730": { "label": "开发服务器端口", "onAutoForward": "notify" },
|
||
"4731": { "label": "预览服务器端口", "onAutoForward": "notify" }
|
||
},
|
||
"remoteEnv": {
|
||
"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}",
|
||
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/node_modules/.bin:${containerEnv:HOME}/.bun/bin:${containerEnv:HOME}/.bun/bin/bun-node-fallback-bin"
|
||
},
|
||
"containerEnv": {
|
||
"HOME": "/home/usr_vscode",
|
||
// "NODE_OPTIONS": "--max-old-space-size=4096",
|
||
"TZ": "${localEnv:TZ:Asia/Shanghai}"
|
||
},
|
||
"customizations": {
|
||
"vscode": {
|
||
"extensions": [
|
||
// AI
|
||
"github.copilot-chat",
|
||
"anthropic.claude-code",
|
||
"google.gemini-cli-vscode-ide-companion",
|
||
"vicanent.gcmp",
|
||
// >>>>>
|
||
// "eamodio.gitlens",
|
||
"tu6ge.naive-ui-intelligence",
|
||
"gruntfuggly.todo-tree",
|
||
"lokalise.i18n-ally",
|
||
"vitest.explorer",
|
||
"antfu.unocss",
|
||
"vue.volar",
|
||
// <<<<<
|
||
// 代码质量 / 格式化 / Lint
|
||
"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,
|
||
"git push": false
|
||
},
|
||
// * 尽管使用了“/.*/”,但有些还是会失败,因为有几个错误的默认值:
|
||
// * https://github.com/microsoft/vscode/issues/266651#issuecomment-3292581459
|
||
"chat.tools.terminal.ignoreDefaultAutoApproveRules": true,
|
||
"tasks": {
|
||
"version": "2.0.0",
|
||
"tasks": [
|
||
{
|
||
"type": "npm",
|
||
"script": "dev",
|
||
"label": "🚀 Dev: Run on Folder Open",
|
||
"runOptions": {
|
||
"runOn": "folderOpen"
|
||
},
|
||
"isBackground": true,
|
||
"presentation": {
|
||
"panel": "dedicated"
|
||
}
|
||
}
|
||
]
|
||
},
|
||
// 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",
|
||
"terminal.integrated.defaultProfile.linux": "💲zsh",
|
||
"terminal.integrated.profiles.linux": {
|
||
"💲zsh": {
|
||
"path": "zsh",
|
||
"icon": "terminal-cmd",
|
||
"overrideName": true,
|
||
"color": "terminal.ansiGreen"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"mounts": [
|
||
{
|
||
// 不挂载可能会遇到:`Cannot run macOS (Mach-O) executable in Docker: Exec format error`
|
||
"type": "volume",
|
||
"source": "${localWorkspaceFolderBasename}-node_modules",
|
||
"target": "${containerWorkspaceFolder}/node_modules"
|
||
},
|
||
{
|
||
"type": "volume",
|
||
"source": "devcontainer-pnpm-store",
|
||
"target": "/home/usr_vscode/.pnpm-store"
|
||
},
|
||
{
|
||
"type": "volume",
|
||
"source": "devcontainer-bun-install-cache",
|
||
"target": "/home/usr_vscode/.bun/install/cache"
|
||
// rm -rf ~/.bun/install/cache/*
|
||
},
|
||
{
|
||
"type": "bind",
|
||
"source": "${localWorkspaceFolder}/.devcontainer/onCreateCommand.d",
|
||
"target": "/usr/local/etc/onCreateCommand.d"
|
||
}
|
||
],
|
||
/**
|
||
* 执行顺序总结
|
||
1. initializeCommand (本地主机,容器创建前)
|
||
2. 容器创建
|
||
3. onCreateCommand (容器首次创建时执行一次)
|
||
4. updateContentCommand ()
|
||
5. postCreateCommand (每次容器启动时执行)
|
||
6. 容器启动
|
||
7. postStartCommand (容器内,每次启动)
|
||
8. VS Code 附加到容器
|
||
9. postAttachCommand (容器内,每次附加)
|
||
*/
|
||
"initializeCommand": "echo '↘️ 准备创建容器...'; docker pull ghcr.io/yanhao98/h-devcontainer:main;",
|
||
"onCreateCommand": "echo '↘️ 容器首次创建!'; /usr/local/bin/onCreateCommand.sh",
|
||
"updateContentCommand": "echo '↘️ 容器内容已更新!'; zsh -c 'time pnpm install;'",
|
||
"postCreateCommand": "echo '↘️ 容器已创建!';",
|
||
"postStartCommand": "echo '↘️ 容器启动了!'",
|
||
"postAttachCommand": "echo '↘️ VS Code 已附加到容器!'; zsh -c 'source ~/.zshrc; echo \"$(date +%Y-%m-%dT%H:%M:%S%z) - Welcome to your Dev Container!\"';",
|
||
"waitFor": "updateContentCommand",
|
||
"remoteUser": "usr_vscode"
|
||
}
|