This commit is contained in:
2026-09-10 21:40:31 +08:00
parent eda9909ec8
commit 99263f89e5
5 changed files with 13 additions and 33 deletions
+6 -3
View File
@@ -1,5 +1,7 @@
# 视野后端构建:多阶段编译 → 精简运行镜像(纯 Go + SQLite,无 CGO 依赖)
FROM golang:1.26 AS builder
# 基础镜像仓库:国内直连 docker.io 不通,默认走 DaoCloud 镜像站;构建时可用 --build-arg REGISTRY=docker.io/library 覆盖
ARG REGISTRY=docker.m.daocloud.io/library
FROM ${REGISTRY}/golang:1.26 AS builder
# 国内网络 proxy.golang.org 不通,默认走 goproxy.cn;构建时可用 --build-arg 覆盖
ARG GOPROXY=https://goproxy.cn,direct
@@ -15,7 +17,8 @@ RUN http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY= go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /out/observer-server .
FROM alpine:3.20
ARG REGISTRY=docker.m.daocloud.io/library
FROM ${REGISTRY}/alpine:3.20
# 国内网络 dl-cdn.alpinelinux.org 不通,默认走阿里云镜像;构建时可用 --build-arg 覆盖
ARG APK_MIRROR=https://mirrors.aliyun.com
# 时区对齐宿主(自然日授权语义依赖本地时区)
@@ -33,5 +36,5 @@ COPY --from=builder /build/admin_dist /app/admin_dist
COPY --from=builder /build/h5 /app/h5
# 运行时数据目录(SQLite 库),由 docker-compose 挂载持久化
RUN mkdir -p /app/data
EXPOSE 18080
EXPOSE 8080
ENTRYPOINT ["/app/observer-server"]