Dockerfile
1.1 KB
#FROM golang:latest
#MAINTAINER 陈志颖 <steve.d.chan@qq.com>
#ENV APP_DIR $GOPATH/src/allied-creation-cooperation
#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.io
#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"]