FROM golang:1.19 as builder WORKDIR /workspaces COPY . ./ ENV GOPROXY=https://goproxy.cn,direct RUN go get -d -v ./ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o demo -ldflags="-w -s" main.go FROM alpine:latest as runner WORKDIR /app COPY --from=builder /app/main . COPY --from=builder /app/config ./config RUN echo "https://mirrors.aliyun.com/alpine/v3.8/main/" > /etc/apk/repositories \ && echo "https://mirrors.aliyun.com/alpine/v3.8/community/" >> /etc/apk/repositories \ && apk add --no-cache tzdata \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo Asia/Shanghai > /etc/timezone \ && apk del tzdata EXPOSE 8888 VOLUME ["/app/config","/app/log"] ENTRYPOINT ["./main"] CMD [ "/app/demo" ]