Dockerfile 644 字节
FROM golang:1.13 as builder

ENV GOPROXY https://goproxy.cn
ENV GO111MODULE on

#RUN git clone http://github.com/tiptok/gocomm.git /app/gocomm

WORKDIR /app/ab

COPY go.mod .
#COPY go.sum .
RUN go mod download

COPY . .

RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o ab main.go

#FROM scratch
FROM alpine:latest
RUN apk add --no-cache tzdata \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存
WORKDIR /root/
COPY --from=builder /app/ab .
#RUN ls -l
EXPOSE 8080
CMD ["./ab"]