From 150a29c9d3366187f5bfda03ccd133fa7e71a5c9 Mon Sep 17 00:00:00 2001 From: XOF Date: Tue, 30 Dec 2025 02:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8b38fcf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# 多阶段构建 +FROM golang:1.25-alpine AS builder + +WORKDIR /app + +# 复制代码 +COPY main.go . + +# 编译 +RUN go build -ldflags="-s -w" -o chnroute-service main.go + +# 运行镜像 +FROM alpine:latest + +RUN apk --no-cache add ca-certificates tzdata + +WORKDIR /app + +# 从构建阶段复制二进制文件 +COPY --from=builder /app/chnroute-service . + +# 设置时区 +ENV TZ=Asia/Shanghai + +EXPOSE 8080 + +CMD ["./chnroute-service"]