refactor: devcontainer
Some checks failed
CI/CD Pipeline / playwright (push) Successful in 2m40s
CI/CD Pipeline / build-and-deploy (push) Successful in 1m55s
测试最新依赖 / build-and-test (push) Successful in 1m30s
测试最新依赖 / playwright (push) Failing after 2m12s

This commit is contained in:
严浩
2025-11-23 00:00:26 +08:00
parent 4a5ae8d2de
commit 814130af34
9 changed files with 2912 additions and 2470 deletions

View File

@@ -10,12 +10,10 @@
"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"
"GOOGLE_GEMINI_BASE_URL": "${localEnv:GOOGLE_GEMINI_BASE_URL}"
},
"containerEnv": {
"HOME": "/home/usr_vscode",
// "NODE_OPTIONS": "--max-old-space-size=4096",
"NODE_OPTIONS": "--max-old-space-size=4096",
"TZ": "${localEnv:TZ:Asia/Shanghai}"
},
"customizations": {
@@ -55,88 +53,23 @@
// * 尽管使用了“/.*/”,但有些还是会失败,因为有几个错误的默认值:
// * 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"
}
}
"tasks": { "version": "2.0.0", "tasks": [] },
"terminal.integrated.defaultProfile.linux": "zsh"
}
}
},
"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"
}
// 不挂载还可能会遇到:`Cannot run macOS (Mach-O) executable in Docker: Exec format error`
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume",
"source=${localWorkspaceFolder}/.devcontainer/lifecycle-scripts.d,target=/usr/local/etc/lifecycle-scripts.d,type=bind,consistency=delegated"
],
/**
*
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!\"';",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=delegated",
"initializeCommand": "docker pull ghcr.io/yanhao98/h-devcontainer:main;",
"onCreateCommand": "/usr/local/bin/run-lifecycle-scripts.sh onCreateCommand",
"updateContentCommand": "/usr/local/bin/run-lifecycle-scripts.sh updateContentCommand",
"postCreateCommand": "/usr/local/bin/run-lifecycle-scripts.sh postCreateCommand",
"postStartCommand": "/usr/local/bin/run-lifecycle-scripts.sh postStartCommand",
"postAttachCommand": "/usr/local/bin/run-lifecycle-scripts.sh postAttachCommand",
"waitFor": "updateContentCommand",
"remoteUser": "usr_vscode"
}