From 2f1b34b9b3aca94cf261aac8fec1ce040395ed51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Fri, 20 Aug 2021 15:42:34 +0800 Subject: [PATCH] =?UTF-8?q?:whale:=20=E6=96=B0=E5=A2=9EDockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f48af55 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +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 +FROM golang:alpine as runner +MAINTAINER LiXunHuan(lxh@cxh.cn) +WORKDIR /app +ENV TZ=Asia/Shanghai +COPY --from=builder /builder/app ./app +CMD ./app \ No newline at end of file