Spaces:
Sleeping
Sleeping
| # 使用Go基础镜像 | |
| FROM golang:alpine AS builder | |
| # 安装必要工具 | |
| RUN apk update && apk add --no-cache git upx make sed | |
| WORKDIR /app | |
| # 添加一个 ADD 指令获取时间戳文件,强制后续指令不使用缓存 | |
| ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" checkout | |
| # 先清理工作目录,然后克隆仓库 | |
| RUN rm -rf * && git clone https://github.com/ycvk/monica-proxy.git . \ | |
| && rm -rf .git | |
| # 关键修改:路由路径替换(新增部分) | |
| RUN sed -i 's#e.POST("/v1/chat/completions", handleChatCompletion)#e.POST("/hf/v1/chat/completions", handleChatCompletion)#g' internal/apiserver/router.go && \ | |
| sed -i 's#e.GET("/v1/models", handleListModels)#e.GET("/hf/v1/models", handleListModels)#g' internal/apiserver/router.go | |
| # 后续保持原逻辑 | |
| ARG TARGETOS | |
| ARG TARGETARCH | |
| RUN go mod tidy | |
| RUN make build-${TARGETOS}-${TARGETARCH} | |
| # 最终阶段 | |
| FROM scratch AS final | |
| WORKDIR /data | |
| COPY --from=builder /app/build/monica . | |
| EXPOSE 8080 | |
| CMD ["./monica"] | |