tao-shen Claude Opus 4.6 commited on
Commit
6adea9c
Β·
1 Parent(s): 7152d8b

fix: move ALL app scripts to /scripts/ (outside PERSIST_DIRS)

Browse files

Dataset restore overwrites files in /opt/ and /etc/ with stale
versions from the dataset. Move all Docker image scripts to
/scripts/ which is NOT in PERSIST_DIRS, so they survive restore.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Dockerfile CHANGED
@@ -43,20 +43,19 @@ RUN useradd -m -u 1000 -s /bin/bash -p "$(openssl passwd -6 huggingrun)" user 2>
43
  RUN usermod -p "$(openssl passwd -6 huggingrun)" root
44
  RUN mkdir -p /data
45
 
46
- # nginx + bridge + startup scripts
47
- COPY ubuntu-server/nginx.conf /etc/nginx/nginx.conf
48
- COPY ubuntu-server/ws-ssh-bridge.py /opt/ws-ssh-bridge.py
49
- COPY ubuntu-server/git_sync_daemon.py /opt/git_sync_daemon.py
50
- COPY ubuntu-server/log_streamer.py /opt/log_streamer.py
51
- COPY ubuntu-server/start-server.sh /opt/start-server.sh
52
  COPY scripts /scripts
53
- # nginx.conf AFTER scripts copy (COPY scripts replaces the dir)
54
  COPY ubuntu-server/nginx.conf /scripts/nginx.conf
55
- RUN chmod +x /scripts/entrypoint.sh /opt/start-server.sh
 
 
 
 
56
 
57
  ENV PERSIST_PATH=/data
58
  ENV PYTHONUNBUFFERED=1
59
- ENV RUN_CMD="/opt/start-server.sh"
60
  ENV SSH_PORT=2222
61
 
62
  # Run as root (needed for: apt install persistence, bind mounts, sshd)
 
43
  RUN usermod -p "$(openssl passwd -6 huggingrun)" root
44
  RUN mkdir -p /data
45
 
46
+ # All app scripts go to /scripts/ β€” OUTSIDE persist dirs (/opt, /etc get
47
+ # restored from dataset, which would overwrite Docker image files with stale versions)
 
 
 
 
48
  COPY scripts /scripts
 
49
  COPY ubuntu-server/nginx.conf /scripts/nginx.conf
50
+ COPY ubuntu-server/ws-ssh-bridge.py /scripts/ws-ssh-bridge.py
51
+ COPY ubuntu-server/git_sync_daemon.py /scripts/git_sync_daemon.py
52
+ COPY ubuntu-server/log_streamer.py /scripts/log_streamer.py
53
+ COPY ubuntu-server/start-server.sh /scripts/start-server.sh
54
+ RUN chmod +x /scripts/entrypoint.sh /scripts/start-server.sh
55
 
56
  ENV PERSIST_PATH=/data
57
  ENV PYTHONUNBUFFERED=1
58
+ ENV RUN_CMD="/scripts/start-server.sh"
59
  ENV SSH_PORT=2222
60
 
61
  # Run as root (needed for: apt install persistence, bind mounts, sshd)
scripts/entrypoint.sh CHANGED
@@ -74,12 +74,12 @@ log "[entrypoint] Wrote /etc/huggingrun.env"
74
 
75
  # Step 1: Init β€” download dataset + restore filesystem (foreground so logs are visible)
76
  log "[entrypoint] ── Step 1: Init (download + restore) ──"
77
- python3 -u /opt/git_sync_daemon.py init
78
  log "[entrypoint] ── Init done ──"
79
 
80
  # Step 2: Start background sync-loop daemon
81
  log "[entrypoint] ── Step 2: Starting sync-loop daemon ──"
82
- python3 -u /opt/git_sync_daemon.py sync-loop &
83
  SYNC_PID=$!
84
  log "[entrypoint] Sync daemon PID=${SYNC_PID}"
85
 
 
74
 
75
  # Step 1: Init β€” download dataset + restore filesystem (foreground so logs are visible)
76
  log "[entrypoint] ── Step 1: Init (download + restore) ──"
77
+ python3 -u /scripts/git_sync_daemon.py init
78
  log "[entrypoint] ── Init done ──"
79
 
80
  # Step 2: Start background sync-loop daemon
81
  log "[entrypoint] ── Step 2: Starting sync-loop daemon ──"
82
+ python3 -u /scripts/git_sync_daemon.py sync-loop &
83
  SYNC_PID=$!
84
  log "[entrypoint] Sync daemon PID=${SYNC_PID}"
85
 
ubuntu-server/start-server.sh CHANGED
@@ -57,7 +57,7 @@ fi
57
 
58
  # ── SSE log streamer ──────────────────────────────────────────────
59
  log "[ubuntu] Starting SSE log streamer on 127.0.0.1:7863 ..."
60
- python3 /opt/log_streamer.py &
61
  STREAMER_PID=$!
62
  sleep 1
63
  if kill -0 $STREAMER_PID 2>/dev/null; then
@@ -68,7 +68,7 @@ fi
68
 
69
  # ── WebSocket-to-SSH bridge ───────────────────────────────────────
70
  log "[ubuntu] Starting WS-SSH bridge on 127.0.0.1:7862 ..."
71
- python3 /opt/ws-ssh-bridge.py &
72
  BRIDGE_PID=$!
73
  sleep 1
74
  if kill -0 $BRIDGE_PID 2>/dev/null; then
 
57
 
58
  # ── SSE log streamer ──────────────────────────────────────────────
59
  log "[ubuntu] Starting SSE log streamer on 127.0.0.1:7863 ..."
60
+ python3 /scripts/log_streamer.py &
61
  STREAMER_PID=$!
62
  sleep 1
63
  if kill -0 $STREAMER_PID 2>/dev/null; then
 
68
 
69
  # ── WebSocket-to-SSH bridge ───────────────────────────────────────
70
  log "[ubuntu] Starting WS-SSH bridge on 127.0.0.1:7862 ..."
71
+ python3 /scripts/ws-ssh-bridge.py &
72
  BRIDGE_PID=$!
73
  sleep 1
74
  if kill -0 $BRIDGE_PID 2>/dev/null; then