Lenson commited on
Commit
49de6ec
·
1 Parent(s): 5a5b104

feat: add HF Dataset sync for config persistence, install huggingface-hub

Browse files
Files changed (4) hide show
  1. .hf/setup.sh +21 -0
  2. Dockerfile +4 -2
  3. Dockerfile.hfspaces +4 -2
  4. config/default.yaml +1 -1
.hf/setup.sh CHANGED
@@ -5,6 +5,10 @@ echo "========================================"
5
  echo " Codex Proxy - HF Spaces Setup"
6
  echo "========================================"
7
 
 
 
 
 
8
  # Ensure data directories exist
9
  mkdir -p /app/data
10
  mkdir -p /app/config
@@ -14,6 +18,23 @@ if [ -n "$HF_SPACE_ID" ]; then
14
  echo "Running on Hugging Face Spaces: $HF_SPACE_ID"
15
  fi
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # Change to app directory
18
  cd /app
19
 
 
5
  echo " Codex Proxy - HF Spaces Setup"
6
  echo "========================================"
7
 
8
+ # Configuration
9
+ HF_DATASET_NAME="${HF_DATASET_NAME:-lenson78/codex-proxy-data}"
10
+ HF_TOKEN="${HF_TOKEN:-}"
11
+
12
  # Ensure data directories exist
13
  mkdir -p /app/data
14
  mkdir -p /app/config
 
18
  echo "Running on Hugging Face Spaces: $HF_SPACE_ID"
19
  fi
20
 
21
+ # Download config from HF Dataset if exists
22
+ if [ -n "$HF_TOKEN" ]; then
23
+ echo "Downloading config from HF Dataset: $HF_DATASET_NAME"
24
+
25
+ # Download data directory
26
+ huggingface-cli download "$HF_DATASET_NAME" data/ --repo-type dataset --local-dir /app/data --local-dir-use-symlinks False 2>/dev/null || \
27
+ echo "No data directory in dataset, starting fresh"
28
+
29
+ # Download config directory
30
+ huggingface-cli download "$HF_DATASET_NAME" config/ --repo-type dataset --local-dir /app/config --local-dir-use-symlinks False 2>/dev/null || \
31
+ echo "No config directory in dataset, using defaults"
32
+
33
+ echo "Config downloaded successfully"
34
+ else
35
+ echo "HF_TOKEN not set, using default config"
36
+ fi
37
+
38
  # Change to app directory
39
  cd /app
40
 
Dockerfile CHANGED
@@ -1,10 +1,12 @@
1
  FROM node:20-slim
2
 
3
  # curl: needed by setup-curl.ts and full-update.ts
4
- # unzip: needed by full-update.ts to extract Codex.app
5
  # gosu: needed by entrypoint to drop from root to node user
 
6
  RUN apt-get update && \
7
- apt-get install -y --no-install-recommends curl unzip ca-certificates gosu && \
 
8
  rm -rf /var/lib/apt/lists/*
9
 
10
  WORKDIR /app
 
1
  FROM node:20-slim
2
 
3
  # curl: needed by setup-curl.ts and full-update.ts
4
+ # unzip: needed for full-update.ts to extract Codex.app
5
  # gosu: needed by entrypoint to drop from root to node user
6
+ # python3 + pip: needed for huggingface-cli
7
  RUN apt-get update && \
8
+ apt-get install -y --no-install-recommends curl unzip ca-certificates gosu python3 python3-pip && \
9
+ pip3 install --no-cache-dir huggingface-hub && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
  WORKDIR /app
Dockerfile.hfspaces CHANGED
@@ -1,10 +1,12 @@
1
  FROM node:20-slim
2
 
3
  # curl: needed by setup-curl.ts and full-update.ts
4
- # unzip: needed by full-update.ts to extract Codex.app
5
  # gosu: needed by entrypoint to drop from root to node user
 
6
  RUN apt-get update && \
7
- apt-get install -y --no-install-recommends curl unzip ca-certificates gosu && \
 
8
  rm -rf /var/lib/apt/lists/*
9
 
10
  WORKDIR /app
 
1
  FROM node:20-slim
2
 
3
  # curl: needed by setup-curl.ts and full-update.ts
4
+ # unzip: needed for full-update.ts to extract Codex.app
5
  # gosu: needed by entrypoint to drop from root to node user
6
+ # python3 + pip: needed for huggingface-cli
7
  RUN apt-get update && \
8
+ apt-get install -y --no-install-recommends curl unzip ca-certificates gosu python3 python3-pip && \
9
+ pip3 install --no-cache-dir huggingface-hub && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
  WORKDIR /app
config/default.yaml CHANGED
@@ -26,7 +26,7 @@ auth:
26
  server:
27
  host: "::"
28
  port: 7860
29
- proxy_api_key: ""
30
  session:
31
  ttl_minutes: 60
32
  cleanup_interval_minutes: 5
 
26
  server:
27
  host: "::"
28
  port: 7860
29
+ proxy_api_key: pwd
30
  session:
31
  ttl_minutes: 60
32
  cleanup_interval_minutes: 5