add all project code

This commit is contained in:
2026-02-14 00:21:43 +08:00
parent d8e0f50895
commit 5a56af2ce8
33 changed files with 19989 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
# 使用官方 Go 镜像作为构建环境
FROM golang:1.21-alpine AS builder
# 设置工作目录
WORKDIR /app
# 安装必要的依赖
RUN apk add --no-cache git
# 复制 go mod 文件
COPY go.mod go.sum ./
# 下载依赖
RUN go mod download
# 复制源代码
COPY . .
# 构建应用
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# 使用轻量级镜像作为运行环境
FROM alpine:latest
# 安装 ca-certificates 用于 HTTPS 请求
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# 从构建阶段复制二进制文件
COPY --from=builder /app/main .
# 创建数据目录
RUN mkdir -p /root/data
# 暴露端口
EXPOSE 8080
# 运行应用
CMD ["./main"]