基于alpine镜像制作go和goimports的Docker镜像

基于alpine制作go docker镜像

步骤

  1. 下载go源码包 For Linux

  2. 解压压缩包至当前文件夹

  3. 编辑Dockerfile

FROM csighub.tencentyun.com/pulse-line/alpine

COPY go /usr/local/go

ENV PATH=$PATH:/usr/local/go/bin:/root/go/bin \
	GOROOT=/usr/local/go

WORKDIR /usr/local/test/

RUN ["go", "install", "golang.org/x/tools/cmd/goimports@latest"]
  1. 制作Docker镜像
docker build -t alpine-go-goimports:v0.0.1 .
  1. 运行容器
docker run -it alpine-go-goimports:v0.0.1