license-server/Dockerfile

32 lines
596 B
Docker
Raw 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 golang:1.22 AS builder
WORKDIR /app
# 拷贝 mod 文件(包含 go.sum 才不会报错)
COPY go.mod go.sum ./
# 先下载基础依赖(避免 build 阶段失败)
RUN go mod download
# 再复制完整代码(这一步才有 fiber/sqlite3 的 import
COPY . .
# 再 tidy确保 go.sum 有完整依赖记录
RUN go mod tidy
# 构建可执行文件
RUN go build -o license-server main.go
# 最小运行时镜像
FROM alpine:latest
RUN apk add --no-cache ca-certificates sqlite
WORKDIR /root/
COPY --from=builder /app/license-server .
EXPOSE 13579
CMD ["./license-server"]