FROM 192.168.0.243:5000/mmm/allied-creation-cooperation:20210908 #FROM golang:latest MAINTAINER 陈志颖 <steve.d.chan@qq.com> ENV APP_DIR $GOPATH/src/allied-creation-cooperation-20210909 RUN mkdir -p $APP_DIR WORKDIR $APP_DIR/ COPY ./pkg pkg COPY ./config config COPY ./go.mod go.mod COPY ./go.sum go.sum COPY ./main.go main.go RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] ENV GO111MODULE on ENV GOPROXY https://goproxy.cn RUN ["go","mod","tidy"] RUN ["ls"] RUN ["go","build"] ENTRYPOINT ["./allied-creation-cooperation"] ############################## ### STEP 1 build executable binary ############################## #FROM golang:latest AS builder #MAINTAINER 陈志颖 <steve.d.chan@qq.com> #RUN mkdir /app #WORKDIR /app #COPY . /app #RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] #RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" CGO_ENABLED=0 GOOS=linux go build -o allied-creation-cooperation # ############################## ### STEP 2 build a small image ############################# #FROM scratch as final #COPY --from=builder /app/allied-creation-cooperation /app/allied-creation-cooperation #ENTRYPOINT ["./app/allied-creation-cooperation"]