From befc20ef584655f2b38b5964534526131d6231d0 Mon Sep 17 00:00:00 2001 From: godo Date: Tue, 6 Aug 2024 03:06:02 +0000 Subject: [PATCH] add Dockerfile. Signed-off-by: godo --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fcc7181 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:latest + +# 设置工作目录 +WORKDIR /app/ + +# 将当前目录的内容复制到容器中的/app目录 +COPY . . +ENV GOPATH=$GOPATH:/app/ GOPROXY=https://mirrors.aliyun.com/goproxy,https://goproxy.cn,direct +# 构建二进制文件 +RUN go build -o godoos ./godo/main.go + +# 使用更小的基础镜像用于最终的部署 +FROM alpine:latest +WORKDIR /app + +# 将构建好的二进制文件复制到新的镜像中 +COPY --from=0 /app/godoos /app/ +# 复制前端构建结果 +COPY --from=0 /app/frontend/dist /app/dist + +# 暴露端口 +EXPOSE 8210 + +# 运行命令 +CMD ["./godoos"] \ No newline at end of file