FROM golang:1.17-alpine3.13 as builder
RUN mkdir /src
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# eg add gcc 
RUN apk add build-base
ADD . /src
WORKDIR /src
RUN go env -w GOPROXY=https://goproxy.cn,direct && go mod tidy
RUN GOPROXY=https://goproxy.cn go build -o main.bin main.go  && chmod +x main.bin

FROM alpine:3.12
ENV ZONEINFO=/app/zoneinfo.zip
RUN mkdir /app
WORKDIR /app

COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /app
COPY --from=builder /src/main.bin /app/main.bin
ENTRYPOINT  ["./app/main.bin"]
EXPOSE 80

发表评论

您的电子邮箱地址不会被公开。

Captcha Code