axm0121 commited on
Commit
5f206f8
·
0 Parent(s):

Compact deployment history before b1cd0f7fa56d

Browse files
Files changed (7) hide show
  1. .gitattributes +36 -0
  2. BUILD_INFO.json +9 -0
  3. Dockerfile +23 -0
  4. README.md +25 -0
  5. UPSTREAM_VERSION +1 -0
  6. codex2api +3 -0
  7. entrypoint.sh +79 -0
.gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ codex2api filter=lfs diff=lfs merge=lfs -text
BUILD_INFO.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "upstream_repo": "https://github.com/james-6-23/codex2api.git",
3
+ "upstream_sha": "b1cd0f7fa56d98e9712ccae2942fc7b443e0929a",
4
+ "upstream_short_sha": "b1cd0f7fa56d",
5
+ "upstream_base_version": "v2.9.3",
6
+ "build_version": "v2.9.3+overdraft.b1cd0f7fa56d",
7
+ "workflow_run_id": "34079964430",
8
+ "workflow_run_attempt": "1"
9
+ }
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ghcr.io/james-6-23/codex2api:latest
2
+
3
+ USER root
4
+
5
+ # Keep the upstream runtime image and replace only the service produced by the
6
+ # scheduled patch builder. UPSTREAM_VERSION records the exact tested source.
7
+ COPY --from=redis:7-alpine /usr/local/bin/redis-server /usr/local/bin/redis-server
8
+ COPY --from=redis:7-alpine /usr/local/bin/redis-cli /usr/local/bin/redis-cli
9
+ COPY --chmod=755 codex2api /usr/local/bin/codex2api
10
+ COPY UPSTREAM_VERSION /etc/codex2api-upstream-version
11
+ COPY BUILD_INFO.json /etc/codex2api-build-info.json
12
+
13
+ RUN apk add --no-cache libstdc++ tzdata ca-certificates
14
+
15
+ WORKDIR /app
16
+ COPY --chmod=755 entrypoint.sh /app/entrypoint.sh
17
+
18
+ EXPOSE 7860
19
+
20
+ HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=30s \
21
+ CMD wget -q -T 5 -O /dev/null http://127.0.0.1:7860/health || exit 1
22
+
23
+ ENTRYPOINT ["/app/entrypoint.sh"]
README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: SelfCodex2api
3
+ emoji: 💻
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ app_port: 7860
9
+ ---
10
+
11
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
+
13
+ ## Codex 额度透支接入
14
+
15
+ 本 Space 保留原 `ghcr.io/james-6-23/codex2api:latest` 运行基座。自动构建仓库每六小时检测上游 GitHub `main`;发现新 commit 后会在 GitHub Actions 中应用超刷补丁、构建当前上游前端、运行定向测试并生成 Linux 服务文件。只有全部步骤通过才更新本 Space。
16
+
17
+ - 自动构建:<https://github.com/c935289832/codex2api-overdraft-builder/actions>
18
+ - `UPSTREAM_VERSION`:当前已测试并部署的上游 commit。
19
+ - `BUILD_INFO.json`:对应的工作流 run 和构建信息。
20
+ - 启动日志会打印实际运行的上游 commit。
21
+
22
+ - `CODEX_QUOTA_OVERDRAFT_ENABLED=true`:启用 95% 预激活、100% 探测和额度恢复状态机。
23
+ - `CODEX_BIND=0.0.0.0`、`CODEX_PORT=7860`:适配 Space 端口映射。
24
+ - 现有 PostgreSQL/Redis 变量保持不变;不要在 Space Secrets 中提交 token 到仓库。
25
+ - 若改用 SQLite,请设置 `DATABASE_DRIVER=sqlite`、`DATABASE_PATH=/data/codex2api.db` 并挂载 `/data` Persistent Storage。
UPSTREAM_VERSION ADDED
@@ -0,0 +1 @@
 
 
1
+ b1cd0f7fa56d98e9712ccae2942fc7b443e0929a
codex2api ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86d4da3d6afe2f460f6a5ef6c575c7387c63f03a1dfa033cf9128259c8eded65
3
+ size 64168098
entrypoint.sh ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ echo "[entrypoint] starting codex2api on Hugging Face"
5
+
6
+ # ---- defaults ----
7
+ export CODEX_PORT="${CODEX_PORT:-7860}"
8
+ export CODEX_BIND="${CODEX_BIND:-0.0.0.0}"
9
+ export CODEX_QUOTA_OVERDRAFT_ENABLED="${CODEX_QUOTA_OVERDRAFT_ENABLED:-true}"
10
+ export TZ="${TZ:-Asia/Shanghai}"
11
+
12
+ # codex2api standard mode
13
+ export DATABASE_DRIVER="${DATABASE_DRIVER:-postgres}"
14
+ export CACHE_DRIVER="${CACHE_DRIVER:-redis}"
15
+
16
+ # Supabase Postgres usually needs SSL
17
+ export DATABASE_SSLMODE="${DATABASE_SSLMODE:-require}"
18
+
19
+ # local redis inside same container
20
+ export REDIS_ADDR="${REDIS_ADDR:-127.0.0.1:6379}"
21
+ export REDIS_DB="${REDIS_DB:-0}"
22
+
23
+ # ---- required vars ----
24
+ : "${DATABASE_HOST:?DATABASE_HOST is required}"
25
+ : "${DATABASE_PORT:?DATABASE_PORT is required}"
26
+ : "${DATABASE_USER:?DATABASE_USER is required}"
27
+ : "${DATABASE_PASSWORD:?DATABASE_PASSWORD is required}"
28
+ : "${DATABASE_NAME:?DATABASE_NAME is required}"
29
+
30
+ # ---- start local redis ----
31
+ if [ -n "${REDIS_PASSWORD:-}" ]; then
32
+ echo "[entrypoint] starting local redis with password"
33
+ redis-server \
34
+ --daemonize yes \
35
+ --bind 127.0.0.1 \
36
+ --port 6379 \
37
+ --save "" \
38
+ --appendonly no \
39
+ --loglevel warning \
40
+ --requirepass "${REDIS_PASSWORD}"
41
+ else
42
+ echo "[entrypoint] starting local redis without password"
43
+ redis-server \
44
+ --daemonize yes \
45
+ --bind 127.0.0.1 \
46
+ --port 6379 \
47
+ --save "" \
48
+ --appendonly no \
49
+ --loglevel warning
50
+ fi
51
+
52
+ # ---- wait for redis ----
53
+ i=0
54
+ until [ "$i" -ge 20 ]
55
+ do
56
+ if [ -n "${REDIS_PASSWORD:-}" ]; then
57
+ if redis-cli -h 127.0.0.1 -p 6379 -a "${REDIS_PASSWORD}" ping >/dev/null 2>&1; then
58
+ break
59
+ fi
60
+ else
61
+ if redis-cli -h 127.0.0.1 -p 6379 ping >/dev/null 2>&1; then
62
+ break
63
+ fi
64
+ fi
65
+ i=$((i+1))
66
+ sleep 1
67
+ done
68
+
69
+ echo "[entrypoint] redis ready"
70
+ echo "[entrypoint] DATABASE_HOST=${DATABASE_HOST}"
71
+ echo "[entrypoint] DATABASE_PORT=${DATABASE_PORT}"
72
+ echo "[entrypoint] DATABASE_NAME=${DATABASE_NAME}"
73
+ echo "[entrypoint] REDIS_ADDR=${REDIS_ADDR}"
74
+ echo "[entrypoint] CODEX_PORT=${CODEX_PORT}"
75
+ if [ -f /etc/codex2api-upstream-version ]; then
76
+ echo "[entrypoint] $(tr '\n' ' ' < /etc/codex2api-upstream-version)"
77
+ fi
78
+
79
+ exec /usr/local/bin/codex2api