golang
容器的 Dockerfile
代码如下
FROM golang:1.17 //golang 版本 LABEL maintainer="fu <fu@nivin.cn>" // 容器作者 ENV GOPROXY https://goproxy.cn,direct //配置golang 代理 # 安装必要的软件包和依赖包 USER root //使用root权限运行 RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \ //将镜像源改为国内环境 sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \ sed -i 's/security-cdn.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \ apt-get update && \ //根据源更新软件包 apt-get upgrade -y && \ apt-get install -y --no-install-recommends \ curl \ zip \ unzip \ git \ vim # 安装 goctl USER root RUN GOPROXY=https://goproxy.cn/,direct go install github.com/tal-tech/go-zero/tools/goctl@cli # 安装 protoc USER root RUN curl -L -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/protoc-3.19.1-linux-x86_64.zip && \ unzip -d /tmp/protoc /tmp/protoc.zip && \ mv /tmp/protoc/bin/protoc $GOPATH/bin # 安装 protoc-gen-go USER root RUN go get -u github.com/golang/protobuf/protoc-gen-go@v1.4.0 # $GOPATH/bin添加到环境变量中 ENV PATH $GOPATH/bin:$PATH # 清理垃圾 USER root RUN apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ rm /var/log/lastlog /var/log/faillog # 设置工作目录 WORKDIR /usr/src/code EXPOSE 8000 EXPOSE 8001 EXPOSE 8002 EXPOSE 8003 EXPOSE 9000 EXPOSE 9001 EXPOSE 9002 EXPOSE 9003
原文链接:https://blog.csdn.net/qq_16014497/article/details/122543234?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165934461816782390562794%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165934461816782390562794&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-19-122543234-null-null.article_score_rank_blog&utm_term=%E6%90%AD%E5%BB%BAcdn
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/6140