remote-task-excutor-cli/Dockerfile.server

45 lines
1.4 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 第一阶段构建阶段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
WORKDIR /app
# 先复制依赖文件,利用缓存
COPY go.mod go.sum ./
# 复制源代码
COPY . .
# 设置 Go 代理
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod tidy && go mod download
# 构建应用server 命令)
RUN CGO_ENABLED=0 GOOS=linux go build -o remote-task-executor-server -ldflags="-w -s" .
# 第二阶段:运行阶段
FROM 172.20.32.159/pipeline-service/pipeline-convert:running
WORKDIR /app
# 安装必要的工具(如果需要)
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
# && apk update \
# && apk add --no-cache ca-certificates tzdata
# 设置时区
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"]