Dockerfile
891 字节
#FROM golang:1.14
#ENV APP_DIR $GOPATH/src/partner
#RUN mkdir -p $APP_DIR
#WORKDIR $APP_DIR/
#COPY ./pkg pkg
#COPY ./conf conf
#COPY ./go.mod go.mod
#COPY ./main.go main.go
#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
#ENV GO111MODULE on
#ENV GOPROXY https://goproxy.cn,direct
#RUN ["go","mod","tidy"]
#RUN ["go","build"]
#EXPOSE 8082
#ENTRYPOINT ["./partner"]
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" GOFLAGS="-mod=vendor" CGO_ENABLED=0 GOOS=linux go build -o partner
############################
# STEP 2 build a small image
###########################
FROM scratch as final
COPY --from=builder /app/partner /app/partner
COPY --from=builder /app/conf/ /app/conf
ENTRYPOINT ["./app/partner"]