cjovs commited on
Commit
1caafb1
·
verified ·
1 Parent(s): 358e245

Enable startup-time CPA auto-update with bucket-safe auth paths

Browse files

Keep config.yaml unchanged, align auth persistence to /data/auths, and refresh CLIProxyAPI from the latest GitHub release on each container start with a bundled-binary fallback.

Files changed (2) hide show
  1. Dockerfile +2 -19
  2. start.sh +42 -0
Dockerfile CHANGED
@@ -23,25 +23,8 @@ COPY supabase-sync.sh /app/supabase-sync.sh
23
  RUN chmod +x /app/supabase-sync.sh
24
 
25
  # Create startup script
26
- RUN echo '#!/bin/bash\n\
27
- \n\
28
- # Replace environment variables in config\n\
29
- envsubst < /app/config.template.yaml > /app/config.yaml\n\
30
- \n\
31
- # Create auths directory\n\
32
- mkdir -p /data/auths\n\
33
- \n\
34
- # Download auth files from Supabase Storage\n\
35
- echo "=== Downloading auth files from Supabase ==="\n\
36
- /app/supabase-sync.sh download || echo "Supabase download skipped"\n\
37
- \n\
38
- echo "=== Auth files loaded: $(find /data/auths -name "*.json" | wc -l) ==="\n\
39
- \n\
40
- # Start file watcher in background (sync changes to Supabase)\n\
41
- /app/supabase-sync.sh watch &\n\
42
- \n\
43
- exec ./cli-proxy-api -config config.yaml\n\
44
- ' > /app/start.sh && chmod +x /app/start.sh
45
 
46
  EXPOSE 7860
47
 
 
23
  RUN chmod +x /app/supabase-sync.sh
24
 
25
  # Create startup script
26
+ COPY start.sh /app/start.sh
27
+ RUN chmod +x /app/start.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  EXPOSE 7860
30
 
start.sh ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Replace environment variables in config
4
+ envsubst < /app/config.template.yaml > /app/config.yaml
5
+
6
+ # Keep auth files on the persistent bucket mount.
7
+ AUTH_DIR="/data/auths"
8
+ mkdir -p "${AUTH_DIR}"
9
+
10
+ # Try to refresh CLI Proxy API from the latest GitHub release, but keep
11
+ # the bundled binary as a fallback so a transient GitHub failure does not
12
+ # block startup.
13
+ echo "=== Checking latest CLI Proxy API release ==="
14
+ TMP_DIR=$(mktemp -d)
15
+ LATEST_URL=$(curl -fsSL https://api.github.com/repos/router-for-me/CLIProxyAPI/releases/latest | jq -r '.assets[] | select(.name | test("linux.*amd64.*tar.gz")) | .browser_download_url' | head -n 1)
16
+
17
+ if [ -n "${LATEST_URL}" ] && [ "${LATEST_URL}" != "null" ]; then
18
+ if curl -fsSL "${LATEST_URL}" -o "${TMP_DIR}/cli-proxy-api.tar.gz" && tar -xzf "${TMP_DIR}/cli-proxy-api.tar.gz" -C "${TMP_DIR}"; then
19
+ LATEST_BIN=$(find "${TMP_DIR}" -name "cli-proxy-api" -type f | head -n 1)
20
+ if [ -n "${LATEST_BIN}" ]; then
21
+ install -m 755 "${LATEST_BIN}" /app/cli-proxy-api
22
+ echo "=== Updated CLI Proxy API from latest GitHub release ==="
23
+ else
24
+ echo "=== Latest release extracted without cli-proxy-api; using bundled binary ==="
25
+ fi
26
+ else
27
+ echo "=== Latest release download failed; using bundled binary ==="
28
+ fi
29
+ else
30
+ echo "=== Latest release lookup failed; using bundled binary ==="
31
+ fi
32
+ rm -rf "${TMP_DIR}"
33
+
34
+ echo "=== Downloading auth files from Supabase ==="
35
+ /app/supabase-sync.sh download || echo "Supabase download skipped"
36
+
37
+ echo "=== Auth files loaded: $(find "${AUTH_DIR}" -name "*.json" | wc -l) ==="
38
+
39
+ # Start file watcher in background (sync changes to Supabase)
40
+ /app/supabase-sync.sh watch &
41
+
42
+ exec /app/cli-proxy-api -config /app/config.yaml