定时任务:
- 执行类型改为 Shell脚本/Python脚本/自定义命令 三选一
- Shell/Python 类型下拉关联脚本库, 选择后预览脚本内容
- 卡片显示关联脚本名 (Preload Script 已就绪)
- 去掉 playbook 类型
脚本库:
- 去掉 powershell/yaml, 只保留 shell + python
- 后端 validation 同步 oneof=shell python
涉及文件:
- script-helpers.tsx: scriptTypes 去掉 powershell/yaml
- CronJobFormDialog.tsx: 完整重写, 脚本库下拉+预览
- CronJobManager.tsx: type 标签对齐, 脚本名展示
- automation.go: CronJob type oneof 改 shell/python/command
Script type oneof 改 shell/python
94 lines
3.4 KiB
Docker
94 lines
3.4 KiB
Docker
# ============================================================
|
||
# AIOps Backend + Agent 多阶段 Dockerfile
|
||
# Stage 1: 编译后端 (Go 1.24)
|
||
# Stage 2: 交叉编译 Agent (Go 1.24, linux-amd64/arm64 + darwin-arm64)
|
||
# Stage 3: 运行时 (Alpine)
|
||
# 署名 Logan.Li
|
||
# ============================================================
|
||
|
||
# 构建参数 — 版本号通过 git tag 或环境变量注入
|
||
ARG VERSION=dev
|
||
ARG BUILD_TIME=unknown
|
||
|
||
# ==================== Stage 1: Backend Builder ====================
|
||
FROM golang:1.24-alpine AS builder
|
||
|
||
WORKDIR /app
|
||
|
||
# 使用国内 Alpine 镜像源加速 // Logan.Li
|
||
RUN sed -i 's|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g' /etc/apk/repositories
|
||
RUN apk add --no-cache git ca-certificates tzdata
|
||
|
||
ENV TZ=Asia/Shanghai
|
||
ENV GOPROXY=https://goproxy.cn,direct
|
||
ENV GONOSUMCHECK=*
|
||
|
||
# 复制后端 go.mod(利用 Docker 层缓存)
|
||
COPY backend/go.mod backend/go.sum ./
|
||
RUN go mod download
|
||
|
||
# 复制后端源码
|
||
COPY backend/ ./
|
||
|
||
# 构建后端二进制(注入版本号)
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||
-ldflags="-w -s -X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME}" \
|
||
-o aiops ./cmd/
|
||
|
||
# ==================== Stage 2: Agent Builder ====================
|
||
FROM golang:1.24-alpine AS agent-builder
|
||
|
||
WORKDIR /agent
|
||
|
||
ENV GOPROXY=https://goproxy.cn,direct
|
||
ENV GOSUMDB=off
|
||
|
||
# 复制 agent go.mod
|
||
COPY agent/go.mod agent/go.sum ./
|
||
RUN go mod download
|
||
|
||
# 复制 agent 源码
|
||
COPY agent/ ./
|
||
|
||
# 交叉编译三个平台的 agent 二进制(注入版本号)
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" -o bin/aiops-agent-linux-amd64 . && \
|
||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" -o bin/aiops-agent-linux-arm64 . && \
|
||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" -o bin/aiops-agent-darwin-arm64 .
|
||
|
||
# ==================== Stage 3: Runtime ====================
|
||
FROM alpine:latest
|
||
|
||
# 使用国内 Alpine 镜像源加速 // Logan.Li
|
||
RUN sed -i 's|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g' /etc/apk/repositories
|
||
|
||
# 安装运行时依赖(bash=kubectl交互终端,curl=健康检查,openssh-client=SSH远程安装agent,kubectl=集群命令行管理,ansible=自动化运维)
|
||
RUN apk --no-cache add ca-certificates tzdata bash curl openssh-client ansible sshpass && \
|
||
curl -sLO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
|
||
chmod +x kubectl && mv kubectl /usr/local/bin/
|
||
|
||
ENV TZ=Asia/Shanghai
|
||
|
||
WORKDIR /app
|
||
|
||
# 复制后端二进制
|
||
COPY --from=builder /app/aiops .
|
||
|
||
# 创建运行时目录(agent 二进制 + 安装脚本)
|
||
RUN mkdir -p /app/agent/bin /app/agent/deploy
|
||
|
||
# 复制 agent 二进制(三个平台)
|
||
COPY --from=agent-builder /agent/bin/aiops-agent-linux-amd64 /app/agent/bin/
|
||
COPY --from=agent-builder /agent/bin/aiops-agent-linux-arm64 /app/agent/bin/
|
||
COPY --from=agent-builder /agent/bin/aiops-agent-darwin-arm64 /app/agent/bin/
|
||
|
||
# 复制 agent 安装脚本和 systemd service 模板
|
||
COPY agent/deploy/install.sh /app/agent/deploy/
|
||
COPY agent/deploy/aiops-agent.service /app/agent/deploy/
|
||
|
||
EXPOSE 8080
|
||
|
||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||
CMD curl -f http://localhost:8080/health || exit 1
|
||
|
||
CMD ["./aiops"]
|