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 中国大陆许可协议进行许可。

posted @   逢生博客  阅读(151)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 晚安 顏人中
  2. 2 出山 花粥 / 王胜娚
  3. 3 我们俩 郭顶
  4. 4 日落大道 梁博
  5. 5 像鱼 王贰浪
  6. 6 把回忆拼好给你 王贰浪
  7. 7 时光背面的我 刘至佳 / 韩瞳
  8. 8 愿你余生漫长 王贰浪
  9. 9 追寻你 王天戈 / 川青
  10. 10 夜空中最亮的星 逃跑计划
  11. 11 孤勇者 陈奕迅
  12. 12 不为谁而作的歌 林俊杰
  13. 13 消愁 毛不易
  14. 14 这一生关于你的风景 隔壁老樊
晚安 - 顏人中
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.