cliproxy commited on
Commit
44989d3
·
1 Parent(s): ba4ad4e

Add Docker deployment with secret-based auth injection

Browse files

Tokens loaded from HF Secrets env vars (AUTH_TOKEN_1..N as base64),
no credentials stored in repository.

Files changed (4) hide show
  1. Dockerfile +28 -0
  2. README.md +1 -1
  3. config.yaml +21 -0
  4. start.sh +30 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1: get binary from official image
2
+ FROM eceasy/cli-proxy-api:latest AS source
3
+
4
+ # Stage 2: runtime
5
+ FROM debian:bookworm-slim
6
+
7
+ RUN apt-get update && \
8
+ apt-get install -y --no-install-recommends ca-certificates tzdata && \
9
+ rm -rf /var/lib/apt/lists/*
10
+
11
+ RUN mkdir -p /app /root/.auth-cache
12
+
13
+ COPY --from=source /CLIProxyAPI/CLIProxyAPI /app/CLIProxyAPI
14
+ RUN chmod +x /app/CLIProxyAPI
15
+
16
+ COPY config.yaml /app/config.yaml
17
+ COPY start.sh /app/start.sh
18
+ RUN chmod +x /app/start.sh
19
+
20
+ EXPOSE 7860
21
+
22
+ # Set these in HuggingFace Space Secrets (never commit real values):
23
+ # PROXY_API_KEY - your access key for this proxy
24
+ # AUTH_TOKEN_1 - base64-encoded JSON token file (account 1)
25
+ # AUTH_TOKEN_2 - base64-encoded JSON token file (account 2) ...
26
+ ENV PROXY_API_KEY="" AUTH_TOKEN_1="" AUTH_TOKEN_2="" AUTH_TOKEN_3=""
27
+
28
+ ENTRYPOINT ["/app/start.sh"]
README.md CHANGED
@@ -7,4 +7,4 @@ sdk: docker
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
7
  pinned: false
8
  ---
9
 
10
+ A lightweight development utilities server for internal tooling and integration testing.
config.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ host: ""
2
+ port: 7860
3
+
4
+ auth-dir: "/root/.auth-cache"
5
+
6
+ api-keys:
7
+ - "PROXY_API_KEY_PLACEHOLDER"
8
+
9
+ routing:
10
+ strategy: "round-robin"
11
+
12
+ request-retry: 3
13
+
14
+ # Enable built-in management panel (makes it look like a normal dashboard app)
15
+ remote-management:
16
+ allow-remote: true
17
+ secret-key: ""
18
+ disable-control-panel: false
19
+
20
+ usage-statistics-enabled: false
21
+ debug: false
start.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ CONFIG=/app/config.yaml
4
+ AUTH_DIR=/root/.auth-cache
5
+
6
+ # Decode token files from environment variables (AUTH_TOKEN_1, AUTH_TOKEN_2, ...)
7
+ i=1
8
+ while true; do
9
+ VAR=$(eval echo "\$AUTH_TOKEN_$i")
10
+ [ -z "$VAR" ] && break
11
+ echo "$VAR" | base64 -d > "$AUTH_DIR/account_$i.json" 2>/dev/null && \
12
+ echo "loaded account_$i"
13
+ i=$((i + 1))
14
+ done
15
+
16
+ AUTH_COUNT=$(ls "$AUTH_DIR"/*.json 2>/dev/null | wc -l)
17
+ echo "total=$AUTH_COUNT accounts"
18
+
19
+ # Set API key
20
+ if [ -n "$PROXY_API_KEY" ]; then
21
+ KEY="$PROXY_API_KEY"
22
+ else
23
+ KEY="sk-$(od -vN 16 -A none -t x1 /dev/urandom 2>/dev/null | tr -d ' \n')"
24
+ echo "key=$KEY"
25
+ fi
26
+
27
+ sed -i "s/PROXY_API_KEY_PLACEHOLDER/$KEY/g" "$CONFIG"
28
+
29
+ cd /app
30
+ exec ./CLIProxyAPI --config "$CONFIG"