Spaces:
Running
Running
asemxin
commited on
Commit
·
5678c30
0
Parent(s):
Initial commit: CLIProxyAPI Docker setup for HF Spaces
Browse files- Dockerfile +45 -0
- README.md +37 -0
Dockerfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Build stage
|
| 2 |
+
FROM golang:1.24-alpine AS builder
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Install git for go mod download
|
| 7 |
+
RUN apk add --no-cache git
|
| 8 |
+
|
| 9 |
+
# Clone the repository
|
| 10 |
+
RUN git clone https://github.com/router-for-me/CLIProxyAPI.git .
|
| 11 |
+
|
| 12 |
+
ARG VERSION=dev
|
| 13 |
+
ARG COMMIT=none
|
| 14 |
+
ARG BUILD_DATE=unknown
|
| 15 |
+
|
| 16 |
+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.Commit=${COMMIT}' -X 'main.BuildDate=${BUILD_DATE}'" -o ./CLIProxyAPI ./cmd/server/
|
| 17 |
+
|
| 18 |
+
# Runtime stage
|
| 19 |
+
FROM alpine:3.22.0
|
| 20 |
+
|
| 21 |
+
RUN apk add --no-cache tzdata
|
| 22 |
+
|
| 23 |
+
# Create non-root user for HF Spaces
|
| 24 |
+
RUN adduser -D -u 1000 user
|
| 25 |
+
|
| 26 |
+
RUN mkdir -p /CLIProxyAPI && chown -R user:user /CLIProxyAPI
|
| 27 |
+
|
| 28 |
+
COPY --from=builder /app/CLIProxyAPI /CLIProxyAPI/CLIProxyAPI
|
| 29 |
+
COPY --from=builder /app/config.example.yaml /CLIProxyAPI/config.example.yaml
|
| 30 |
+
|
| 31 |
+
WORKDIR /CLIProxyAPI
|
| 32 |
+
|
| 33 |
+
# HF Spaces requires port 7860
|
| 34 |
+
EXPOSE 7860
|
| 35 |
+
|
| 36 |
+
ENV TZ=Asia/Shanghai
|
| 37 |
+
ENV PORT=7860
|
| 38 |
+
|
| 39 |
+
RUN cp /usr/share/zoneinfo/${TZ} /etc/localtime && echo "${TZ}" > /etc/timezone
|
| 40 |
+
|
| 41 |
+
# Switch to non-root user
|
| 42 |
+
USER user
|
| 43 |
+
|
| 44 |
+
# Start with port 7860 for HF Spaces
|
| 45 |
+
CMD ["./CLIProxyAPI", "--port", "7860", "--host", "0.0.0.0"]
|
README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: CLIProxyAPI
|
| 3 |
+
emoji: 🚀
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# CLIProxyAPI
|
| 12 |
+
|
| 13 |
+
A proxy server that provides OpenAI/Gemini/Claude/Codex compatible API interfaces for CLI.
|
| 14 |
+
|
| 15 |
+
## Features
|
| 16 |
+
|
| 17 |
+
- OpenAI/Gemini/Claude compatible API endpoints
|
| 18 |
+
- OpenAI Codex support (GPT models) via OAuth login
|
| 19 |
+
- Claude Code support via OAuth login
|
| 20 |
+
- Streaming and non-streaming responses
|
| 21 |
+
- Function calling/tools support
|
| 22 |
+
- Multimodal input support (text and images)
|
| 23 |
+
- Multiple accounts with round-robin load balancing
|
| 24 |
+
|
| 25 |
+
## Usage
|
| 26 |
+
|
| 27 |
+
After deployment, you can access the API at your Space URL.
|
| 28 |
+
|
| 29 |
+
## Configuration
|
| 30 |
+
|
| 31 |
+
Set the following environment variables in your Space settings:
|
| 32 |
+
|
| 33 |
+
- `API_KEYS`: Comma-separated list of API keys for authentication
|
| 34 |
+
|
| 35 |
+
## More Information
|
| 36 |
+
|
| 37 |
+
Visit [CLIProxyAPI Documentation](https://help.router-for.me/) for more details.
|