2026-01-30 14:39:25 +08:00
|
|
|
|
# 第一阶段:构建阶段FROM 172.20.32.187/pipeline-service/golang:1.24.5-alpine3.22 AS builder
|
|
|
|
|
|
FROM 172.20.32.159/pipeline-service/golang:1.24.5-alpine3.22 AS builder
|
2026-01-29 14:21:21 +08:00
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
# 先复制依赖文件,利用缓存
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
|
# 复制源代码
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
# 设置 Go 代理
|
2026-01-30 14:39:25 +08:00
|
|
|
|
RUN go env -w RUN go env -w GOPROXY=https://goproxy.cn,direct
|
2026-01-29 14:21:21 +08:00
|
|
|
|
RUN go mod tidy && go mod download
|
|
|
|
|
|
# 构建应用(server 命令)
|
|
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o remote-task-executor-server -ldflags="-w -s" .
|
|
|
|
|
|
|
|
|
|
|
|
# 第二阶段:运行阶段
|
2026-01-30 14:39:25 +08:00
|
|
|
|
FROM 172.20.32.159/pipeline-service/pipeline-convert:running
|
2026-01-29 14:21:21 +08:00
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
# 安装必要的工具(如果需要)
|
2026-01-30 14:39:25 +08:00
|
|
|
|
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
|
|
|
|
|
# && apk update \
|
|
|
|
|
|
# && apk add --no-cache ca-certificates tzdata
|
2026-01-29 14:21:21 +08:00
|
|
|
|
|
|
|
|
|
|
# 设置时区
|
|
|
|
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
|
|
|
|
|
|
|
|
# 从构建阶段复制可执行文件
|
|
|
|
|
|
COPY --from=builder /app/remote-task-executor-server /app/
|
|
|
|
|
|
|
|
|
|
|
|
# 设置执行权限
|
|
|
|
|
|
RUN chmod a+x /app/remote-task-executor-server
|
|
|
|
|
|
|
|
|
|
|
|
# 暴露端口
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
|
|
|
|
# 健康检查
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
|
|
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
|
|
|
|
|
|
|
|
|
|
|
|
# 入口点(启动 server)
|
|
|
|
|
|
ENTRYPOINT ["/app/remote-task-executor-server", "server", "--port", "8080"]
|
|
|
|
|
|
|