2021-08-31 09:39:38 +08:00
|
|
|
|
FROM golang:alpine as builder
|
|
|
|
|
MAINTAINER LiXunHuan(lxh@cxh.cn)
|
|
|
|
|
# 创建工作目录,修改alpine源为中科大的源,安装必要工具
|
|
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
|
|
|
|
|
apk update && \
|
|
|
|
|
apk upgrade && \
|
|
|
|
|
apk add ca-certificates gcc g++ && update-ca-certificates && \
|
|
|
|
|
apk add --update tzdata && \
|
|
|
|
|
rm -rf /var/cache/apk/*
|
|
|
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
|
WORKDIR /builder
|
|
|
|
|
COPY . .
|
|
|
|
|
RUN go mod download && go build -o app
|
|
|
|
|
RUN ls -lh && chmod +x ./app
|
2021-09-07 13:41:33 +08:00
|
|
|
|
FROM alpine as runner
|
2021-08-31 09:39:38 +08:00
|
|
|
|
MAINTAINER LiXunHuan(lxh@cxh.cn)
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
|
COPY --from=builder /builder/app ./app
|
|
|
|
|
CMD ./app
|