重新整理物联网服务,分离业务逻辑。

This commit is contained in:
BBIT-Kai
2026-01-05 11:54:33 +08:00
parent e2982b141d
commit 892cb2494e
53 changed files with 558 additions and 26 deletions
+36
View File
@@ -0,0 +1,36 @@
# ==========================
# Stage 1: Build the Go binary
# ==========================
FROM golang:1.21-alpine AS builder
# 设置工作目录
WORKDIR /build
# 复制 go.mod 和 go.sum,先做依赖缓存
COPY go.mod go.sum ./
# 下载依赖(缓存层)
RUN go mod download
# 复制源代码
COPY app/ ./app
# 编译可执行文件
RUN go build -o sentinel ./app/main.go
# ==========================
# Stage 2: 生成最终运行镜像
# ==========================
FROM alpine:3.18
# 安装 ca-certificates,如果程序需要访问 HTTPS
RUN apk add --no-cache ca-certificates
# 设置工作目录
WORKDIR /app
# 复制从 builder 构建好的二进制
COPY --from=builder /build/sentinel .
# 设置默认执行命令
CMD ["./sentinel"]