Dockerfile 1.0 KB
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 443
ENTRYPOINT ["./partner"]

#############################
## STEP 1 build executable binary
#############################
#FROM golang:alpine AS builder
#
#RUN mkdir /app
#WORKDIR /app
#COPY . /app
#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
##RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" GOFLAGS="-mod=vendor" CGO_ENABLED=0 GOOS=linux go build -o partner
#RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" 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"]