Files
openclaw 811574cc6b chore: 构建与仓库整理
- .gitignore 排除运行时产物(run/、cpa/、dist/、二进制、日志)
- dist 构建产物移出版本库(磁盘保留,发布走 Release 产物)
- Makefile/Dockerfile/docker-compose/config.yaml.example 同步 ops-assistant 更名
- 新增 VERSION 文件(0.0.1)
2026-09-13 07:42:49 +08:00

53 lines
1.3 KiB
Docker

# ============ 构建阶段 ============
FROM golang:1.22-bookworm AS builder
ARG VERSION=dev
ARG GIT_COMMIT=unknown
ARG BUILD_TIME=unknown
WORKDIR /build
# 安装 gojieba 依赖
RUN apt-get update && apt-get install -y gcc g++ cmake && rm -rf /var/lib/apt/lists/*
# 先复制依赖文件,利用缓存
COPY go.mod go.sum ./
RUN go mod download
# 复制源码
COPY . .
# 编译
RUN CGO_ENABLED=1 go build \
-ldflags "-X ops-assistant/version.Version=${VERSION} \
-X ops-assistant/version.GitCommit=${GIT_COMMIT} \
-X ops-assistant/version.BuildTime=${BUILD_TIME}" \
-o ops-assistant cmd/main.go
# ============ 运行阶段 ============
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
ENV TZ=Asia/Shanghai
WORKDIR /app
# 从构建阶段复制
COPY --from=builder /build/ops-assistant .
COPY --from=builder /build/templates/ ./templates/
COPY --from=builder /build/config.yaml.example ./config.yaml.example
# gojieba 词典文件
COPY --from=builder /go/pkg/mod/github.com/yanyiwu/[email protected]/dict/ /app/dict/
# 数据目录
VOLUME ["/app/data"]
EXPOSE 9621
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:9621/health || exit 1
ENTRYPOINT ["./ops-assistant"]