code-server
2024-03-29 Updated.
coder 公司在 2019-03 首发可在浏览器访问 VS Code 的 code-server。
使用场景:
- 在远程一台机器上开发,但 SSH 受限,或您需要基于网页访问;
- 在一台不支持安装 VS Code 桌面版的机器上开发应用,如 iPad / 平板电脑或 Chromebook ;
- 体验所有代码都可以在浏览器沙箱中执行的客户端安全优势 .
安装
使用 codercom/code-server 镜像默认无 debian/ubuntu 和包管理环境,安装 CC 编译环境非常麻烦, 使用 基于 ubuntu LTS 二次打包的 linuxserver/code-server 代替。
shell
mkdir -p /share/Container/code
docker run -d \
--name=code \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Asia/Shanghai \
-e PASSWORD=password `#optional` \
-e HASHED_PASSWORD= `#optional` \
-e SUDO_PASSWORD=password `#optional` \
-e SUDO_PASSWORD_HASH= `#optional` \
-e PROXY_DOMAIN=code-server.my.domain `#optional` \
-e DEFAULT_WORKSPACE=/config/workspace `#optional` \
-p 8443:8443 \
-v /share/Container/code:/config \
--restart unless-stopped \
lscr.io/linuxserver/code-server:latest问题:
- 创建容器实例后无法修改密码 修改 /config/.config/code-server/config.yaml 后重启无效;
- 通过网页操作 IDE (后端 node 通过容器环境?)访问 https 会超时失败,如 通过 IDE 安装 go tools 依赖包会失败;
配置通用研测环境
- 必须安装包
apt install vim; - CC
apt update && apt install build-essential; - JDK 有版本要求则从 oracle 官网下载二进制包,否则用系统包管理器安装
apt install openjdk-21-jdk; - Python
apt install python3;
配置 NVM 和 node.js 研测环境
shell
# OPTIONAL: setup proxy
# export https_proxy=localhost:7890
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && nvm install 20ref: https://nodejs.org/en/download/package-manager
配置 Go 研测环境
手动下载和安装 Go 二进制包 https://go.dev/dl/
问题 Failed to find the "go" binary
报错 Failed to find the "go" binary in either GOROOT() or PATH ... 或 Failed to run "go env" to find GOPATH as the "go" binary cannot be found in either GOROOT(undefined) or PATH...
修改 $HOME/.bashrc ,以便在 shell 中找到 go 程序
shell
export PATH="$HOME/pkgs/go/bin:$PATH"
export GOPATH="$HOME/work"
export PATH="$GOPATH/bin:$PATH"
export GO111MODULE=on
export GOPROXY=https://goproxy.cn修改 user settings.json 让 IDE 感知 Go SDK 相关目录
json
{
"go.gopath": "$HOME/work",
"go.goroot": "$HOME/pkgs/go"
}参考
安装的 go 依赖包找不到
通过 vscode 安装的 go 依赖包,系统提示成功,但是二次点击/重启后又提示未安装。
解决方法:通过终端 bash 安装。
