- ExecuteTicket: 检测 ghost_enabled + ALTER TABLE → 走 gh-ost 同步执行 - parseAlterTable: 解析 ALTER TABLE 提取表名和 alter 子句(支持反引号/db.table) - buildGhOstTask: 修复密码传递(加密→解密后传给 gh-ost 命令行) - Dockerfile: 运行阶段下载 gh-ost v1.1.6 Linux amd64 二进制 - ghost_enabled=false 默认关闭,工单流程正常走普通通道 - 端到端验证: ALTER TABLE+ghost_enabled=true → gh-ost; INSERT/关闭 → 普通
24 lines
882 B
Docker
24 lines
882 B
Docker
FROM golang:1.26-bookworm AS build
|
|
|
|
WORKDIR /app
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -o opsxsql ./cmd/server/
|
|
|
|
FROM debian:bookworm-slim
|
|
RUN apt-get update && apt-get install -y ca-certificates sqlite3 curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
# Install gh-ost for online DDL
|
|
RUN GH_OST_VERSION=1.1.6 && \
|
|
curl -fsSL "https://github.com/github/gh-ost/releases/download/v${GH_OST_VERSION}/gh-ost_${GH_OST_VERSION}_linux_amd64.tar.gz" \
|
|
| tar xz -C /usr/local/bin gh-ost && chmod +x /usr/local/bin/gh-ost
|
|
WORKDIR /app
|
|
COPY --from=build /app/opsxsql .
|
|
COPY --from=build /app/cmd/server/seed.go /app/
|
|
COPY --from=build /app/config /app/config
|
|
COPY --from=build /app/internal /app/internal
|
|
COPY --from=build /app/router /app/router
|
|
COPY --from=build /app/sqlite3.db.bak-before-seed ./
|
|
EXPOSE 9000
|
|
CMD ["./opsxsql"]
|