35 lines
637 B
Docker
35 lines
637 B
Docker
# 调度中心 Dockerfile
|
||
FROM golang:1.21-alpine AS builder
|
||
|
||
WORKDIR /app
|
||
|
||
# 安装依赖
|
||
RUN apk add --no-cache git
|
||
|
||
# 复制 go.mod 和 go.sum
|
||
COPY go.mod go.sum ./
|
||
RUN go mod download
|
||
|
||
# 复制源代码
|
||
COPY . .
|
||
|
||
# 构建
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o /scheduler ./cmd/scheduler
|
||
|
||
# 运行镜像
|
||
FROM alpine:latest
|
||
|
||
WORKDIR /app
|
||
|
||
# 安装 ca-certificates(用于 HTTPS)
|
||
RUN apk --no-cache add ca-certificates tzdata
|
||
|
||
# 从构建阶段复制二进制文件
|
||
COPY --from=builder /scheduler /app/scheduler
|
||
COPY --from=builder /app/configs /app/configs
|
||
|
||
# 暴露端口
|
||
EXPOSE 8080 1080
|
||
|
||
# 运行
|
||
ENTRYPOINT ["/app/scheduler"] |