license-server/Dockerfile

31 lines
528 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
# 只复制 go.mod不要求 go.sum 存在)
COPY go.mod ./
# 自动下载基础依赖并生成 go.sum
RUN go mod tidy
# 再复制完整项目代码
COPY . .
# 再执行一次 tidy捕捉全部 import 依赖)
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"]