code-server go环境
docker-compose.yml
version: '3'
services:
code-server:
build:
context: ./code-server/
dockerfile: Dockerfile
image: code-server:4.19.1
container_name: code-server
privileged: true
# restart: always
ports:
- '8080:8080'
environment:
TZ: Asia/Shanghai
# code-server登录密码
PASSWORD: u12345678
SUDO_PASSWORD: root12345678
volumes:
- /etc/localtime:/etc/localtime
- /var/run/docker.sock:/var/run/docker.sock
- ./code-server/local:/home/coder/.local
- ./code-server/config:/home/coder/.config
- ./code-server/project:/home/coder/project
logging:
driver: "json-file"
options:
max-size: "50m"
Dockerfile
FROM codercom/code-server:4.19.1
# apt 国内镜像源
RUN sudo sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN sudo apt-get clean
RUN sudo apt-get update
RUN sudo apt-get install -y vim
RUN sudo apt-get install -y curl
# Go环境依赖
RUN sudo apt-get install -y gcc
RUN sudo apt-get install -y binutils
RUN sudo apt-get install -y bison
RUN sudo apt-get install -y make
# 安装gvm
RUN curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer | bash -s
RUN /bin/bash -c 'source ~/.gvm/scripts/gvm'
# gvm环境变量
RUN sudo sed -i '$aexport GO111MODULE=on' /etc/profile
RUN sudo sed -i '$aexport GOPROXY=https://goproxy.cn,direct' /etc/profile
RUN sudo sed -i '$aexport G_MIRROR=https://golang.google.cn/dl/' /etc/profile
RUN sudo sed -i '$aexport GO_BINARY_BASE_URL=https://golang.google.cn/dl/' /etc/profile
RUN sudo sed -i '$a[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"' /etc/profile
RUN sudo sed -i '$aexport GOROOT_BOOTSTRAP=$GOROOT' /etc/profile
RUN /bin/bash -c 'source /etc/profile'
RUN sudo sed -i '$aexport GO111MODULE=on' /home/coder/.bashrc
RUN sudo sed -i '$aexport GOPROXY=https://goproxy.cn,direct' /home/coder/.bashrc
RUN sudo sed -i '$aexport G_MIRROR=https://golang.google.cn/dl/' /home/coder/.bashrc
RUN sudo sed -i '$aexport GO_BINARY_BASE_URL=https://golang.google.cn/dl/' /home/coder/.bashrc
RUN sudo sed -i '$a[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"' /home/coder/.bashrc
RUN sudo sed -i '$aexport GOROOT_BOOTSTRAP=$GOROOT' /home/coder/.bashrc
RUN /bin/bash -c 'source /home/coder/.bashrc'
WORKDIR /home/coder/project
gvm管理go版本
# 查看可安装版本
gvm listall
# 查看已安装版本
gvm list
# 安装 Go 版本(1.4>版本,需要加上-B)
gvm install go1.21.5 -B
# 使用指定版本
gvm use go1.21.5
# 设置默认版本
gvm use go1.21.5 --default
本文作者:逢生博客
本文链接:https://www.cnblogs.com/wufengsheng/p/17902323.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步