license-server/Dockerfile

34 lines
661 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
# 编译可执行文件(保留 CGo 支持)
RUN go build -o license-server main.go
# ✅ 运行镜像:改为 debian 支持 CGo 二进制
FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /root/
COPY --from=builder /app/license-server .
EXPOSE 13579
CMD ["./license-server"]