CLIProxyAPI / Dockerfile
superxu520's picture
Update Dockerfile
325f0d9 verified
# --- 第一阶段:编译阶段 ---
FROM golang:alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
# 从 GitHub 克隆最新源码
RUN git clone https://github.com/router-for-me/CLIProxyAPI.git .
# 设置 Go 环境
ENV GOTOOLCHAIN=auto
RUN go mod download
# 编译服务器程序
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server
# --- 第二阶段:运行阶段 ---
FROM alpine:latest
# 安装基础运行环境
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /app
# 复制编译出的程序
COPY --from=builder /app/server .
# 关键:复制示例配置文件,解决程序启动时的校验报错
COPY --from=builder /app/config.example.yaml ./config.example.yaml
# 复制静态资源(使用通配符防止报错)
COPY --from=builder /app/static* ./static/
# 适配 Hugging Face 环境变量
ENV PORT=7860
EXPOSE 7860
# 启动程序:使用你在 HF Files 页面创建的 config.yaml
CMD ["./server", "-config", "config.yaml"]