我是 Visual Studio Code 新手。我已经配置了 C/C++ 开发环境,一切正常。
但是,当启动 VS Code 时,我会在右下角收到这些通知。
我的开发过程的一部分涉及使用 Mocha 和 Chai 测试。我的测试文件夹中有一个页面,用于加载所有代码和测试,我可以启动一个运行简单本地服务器的本地节点脚本,在 上访问该页面http://localhost:8080/blahblahblah.html,并查看测试结果。
GitHub 最近发布了 Codespaces,我注册了测试版。如果我开始在 Codespace 中进行开发,我知道那里有一个终端。如果我在该 Codespace 中运行测试服务器,我将如何查看测试结果?是否可以从外部连接到容器中的服务器?什么可以替代我上面显示的 URL?
首先,问题是:有没有办法为 GitHub Codespace 选择平台(例如 x86_64、AMD64、ARM64)?
这是我到目前为止发现的:
尝试1(不起作用):
在 GitHub.com 中,您可以为 Codespace 选择“机器”,但唯一的选项是 RAM 和磁盘大小。
尝试2(编辑:不起作用): devcontainer.json
创建 Codespace 时,您可以通过创建包含两个文件的顶级.devcontainer文件夹来指定选项:devcontainer.json和Dockerfile
在这里您可以自定义运行时、安装的软件包等,但文档没有提及任何有关确定架构的信息...
...但是,VSCode 文档devcontainer.json有一个runArgs选项,“接受 Docker CLI 参数”...
--platform 上的 Docker CLI 文档说你应该能够传递--platform linux/amd64or --platform linux/arm64,但是......
当我尝试这样做时,代码空间会挂起,永远不会完成构建。
尝试 3(进行中):指定Dockerfile
这条路线似乎是最有前途的,但它对我来说都是新的(容器化、代码空间、docker)。尝试 2 和尝试 3 可能会同时发挥作用。不过,目前有太多新的动人的部分,我需要外部帮助。
dpkg --print-architecture或uname -a]参考资料:
https://code.visualstudio.com/docs/remote/devcontainerjson-reference
https://docs.docker.com/engine/reference/commandline/run/
https://docs.docker.com/engine/reference /builder/ …
github docker codespaces vscode-devcontainer github-codespaces
我对 github 代码空间上的子模块有疑问。
当我使用命令时
git submodule update --init
Run Code Online (Sandbox Code Playgroud)
终端显示给我
Warning: Permanently added 'github.com,xxxxx' (ECDSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud) 我正在尝试 GitHub Codespaces,尝试使用 Node 和 Postgres 启动一个应用程序。
\n\n产生以下结果devcontainer.json:
// Update the VARIANT arg in docker-compose.yml to pick a Node.js version: 10, 12, 14 \n{\n "name": "Node.js & PostgreSQL",\n "dockerComposeFile": "docker-compose.yml",\n "service": "app",\n "workspaceFolder": "/workspace",\n\n // Set *default* container specific settings.json values on container create.\n "settings": { \n "terminal.integrated.shell.linux": "/bin/bash",\n "sqltools.connections": [{\n "name": "Container database",\n "driver": "PostgreSQL",\n "previewLimit": 50,\n "server": "localhost",\n "port": 5432,\n "database": "postgres",\n "username": "postgres",\n "password": "postgres"\n }]\n },\n\n // Add the IDs …Run Code Online (Sandbox Code Playgroud) devcontainer.json我使用和设置了 Github codespaces 环境docker-compose.yaml。docker-compose.yml一切工作正常,但是每次需要重新构建容器时,定义的 postgres 数据库都会丢失其数据。
这是底部的部分docker-compose.yml
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: test_user
POSTGRES_DB: test_db
POSTGRES_PASSWORD: test_pass
volumes:
postgres-data:
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我试图将 postgres 数据卷映射到一个postgres-data卷中,但由于某种原因这不起作用。
我做错了什么导致 postgres 数据无法在容器构建之间保留?
README.md当我在 Google Chrome(以及基于 Chromium 的 Brave)上的 GitHub Codespaces 中打开Markdown 预览视图时,我得到:
Error loading webview: Error: Could not register service workers: NotSupportedError: Failed to register a ServiceWorker for scope ('https://....vscode-cdn.net/insider/.../out/vs/workbench/contrib/webview/browser/pre/') with script ('https://....vscode-cdn.net/insider/.../out/vs/workbench/contrib/webview/browser/pre/service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&remoteAuthority=codespaces+vorburger-...'): The user denied permission to use Service Worker..
我如何授予在 Chrom/Chromium/Brave 中使用 Service Workers 的*.github.dev权限*.vscode-cdn.net?
github web-worker service-worker visual-studio-code codespaces
一些 opencv 代码在执行时需要显示 GUI 窗口。相反,它显示Gtk-WARNING **: xxx: cannot open display:. 它发生在网络和桌面应用程序中。是否可以使用 x11 转发之类的功能来启用此功能?谢谢。
我正在尝试使用 Github Codespaces打开此存储库。请注意,此存储库已针对本地devcontainer开发正确配置。
但是,当我尝试在 CodeSpaces 中打开它时,它似乎正确构建了容器,但失败了:(Could not detect any language/platform in the source directory完整日志此处)
我缺少什么?
我尝试在 GitHub Codespaces 中以可见模式运行 Puppeteer 时遇到问题。
我猜是因为 GitHub 没有渲染器以及本地计算机。
有什么方法可以运行 Puppeteer,将其连接到端口以使其可见或其他替代方案,希望对您有所帮助。
我希望它以这种模式运行:
const browser = await puppeteer.launch({ headless: false });
Run Code Online (Sandbox Code Playgroud)
我已经测试过: - 安装一个视图服务器,例如Xvfb。- 配置 Puppeteer 以使用视图服务器。
const browser = await puppeteer.launch({ headless: false, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'], env: { DISPLAY: ':99' } });
-我没有获得好的结果
我希望:在 GitHub Codespaces 或其他替代方案中的端口上运行 Puppeteer。
codespaces ×12
github ×6
node.js ×3
chai ×1
docker ×1
docusaurus ×1
explorer ×1
git ×1
mocha.js ×1
nginx ×1
postgresql ×1
puppeteer ×1
web-worker ×1
x11 ×1