From e6453865c54715c0e2ab255c3dfdd67f80f0e7ee Mon Sep 17 00:00:00 2001 From: dong <1278815766@qq.com> Date: Fri, 27 Dec 2024 19:54:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66cf400..ee5c85d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,29 +4,22 @@ FROM golang:1.23-alpine AS builder # 设置工作目录 WORKDIR /app -# 复制go mod和sum文件 -COPY go.mod go.sum ./ +# 复制源代码 +COPY . . # 下载依赖 RUN go mod download -# 复制源代码 -COPY . . - # 构建应用 RUN CGO_ENABLED=0 GOOS=linux go build -o main . # 使用轻量级的alpine作为运行环境 FROM alpine:latest -# 安装必要的CA证书 -RUN apk --no-cache add ca-certificates - WORKDIR /root/ # 从builder阶段复制编译好的应用 COPY --from=builder /app/main . -COPY .env . # 暴露应用端口(根据实际需要修改) EXPOSE 8080