DanielleNguyen commited on
Commit
78eaa61
·
verified ·
1 Parent(s): 6332598

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +25 -0
  2. README.md +8 -10
  3. config.yaml +56 -0
Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM debian:bookworm-slim
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && \
6
+ apt-get install -y wget ca-certificates curl jq gettext-base && \
7
+ rm -rf /var/lib/apt/lists/*
8
+
9
+ # Download latest sub2api binary for Linux amd64
10
+ RUN LATEST_URL=$(curl -s https://api.github.com/repos/Wei-Shaw/sub2api/releases/latest | \
11
+ jq -r '.assets[] | select(.name | test("linux.*amd64")) | .browser_download_url' | head -1) && \
12
+ echo "Downloading: $LATEST_URL" && \
13
+ wget -q "$LATEST_URL" -O sub2api && \
14
+ chmod +x /app/sub2api
15
+
16
+ # Copy config template
17
+ COPY config.yaml /app/config.template.yaml
18
+
19
+ # Startup script: substitute env vars then launch
20
+ RUN printf '#!/bin/bash\nenvsubst < /app/config.template.yaml > /app/config.yaml\nexec /app/sub2api\n' > /app/start.sh && \
21
+ chmod +x /app/start.sh
22
+
23
+ EXPOSE 7860
24
+
25
+ CMD ["/app/start.sh"]
README.md CHANGED
@@ -1,10 +1,8 @@
1
- ---
2
- title: Sub2api
3
- emoji: 😻
4
- colorFrom: green
5
- colorTo: gray
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: Sub2API
3
+ emoji: 🚀
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ pinned: false
8
+ ---
 
 
config.yaml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server:
2
+ host: "0.0.0.0"
3
+ port: 7860
4
+ mode: "release"
5
+
6
+ database:
7
+ host: "${DATABASE_HOST}"
8
+ # Use Supabase PgBouncer port (6543) to reduce connection usage
9
+ # Direct connection port is 5432, but PgBouncer is recommended for free tier
10
+ port: 6543
11
+ user: "${DATABASE_USER}"
12
+ password: "${DATABASE_PASSWORD}"
13
+ dbname: "${DATABASE_NAME}"
14
+ sslmode: "require"
15
+ # PgBouncer transaction mode: keep pool small
16
+ max_open_conns: 20
17
+ max_idle_conns: 5
18
+ conn_max_lifetime_minutes: 10
19
+ conn_max_idle_time_minutes: 3
20
+
21
+ redis:
22
+ host: "${REDIS_HOST}"
23
+ port: 6379
24
+ password: "${REDIS_PASSWORD}"
25
+ db: 0
26
+ enable_tls: true
27
+
28
+ jwt:
29
+ secret: "${JWT_SECRET}"
30
+ expire_hour: 24
31
+
32
+ totp:
33
+ encryption_key: "${TOTP_ENCRYPTION_KEY}"
34
+
35
+ default:
36
+ admin_email: "${ADMIN_EMAIL}"
37
+ admin_password: "${ADMIN_PASSWORD}"
38
+ user_concurrency: 5
39
+ user_balance: 0
40
+ api_key_prefix: "sk-"
41
+ rate_multiplier: 1.0
42
+
43
+ log:
44
+ level: "info"
45
+ format: "console"
46
+ output:
47
+ to_stdout: true
48
+ to_file: false
49
+
50
+ run_mode: "standard"
51
+
52
+ security:
53
+ url_allowlist:
54
+ enabled: false
55
+ allow_insecure_http: false
56
+ allow_private_hosts: false