soxogvv commited on
Commit
01eea09
Β·
verified Β·
1 Parent(s): 579cc67

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -35
Dockerfile CHANGED
@@ -37,7 +37,7 @@ ENV HOME=/root \
37
  VIRTUAL_ENV=/root/venv \
38
  PIP_NO_CACHE_DIR=1
39
 
40
- # ── Create Python venv + install packages (will be persisted via symlink) ─────
41
  RUN python3 -m venv /root/venv && \
42
  /root/venv/bin/pip install --upgrade pip && \
43
  /root/venv/bin/pip install huggingface_hub
@@ -57,40 +57,32 @@ RUN cd /root/app && npm install --omit=dev
57
  COPY . /root/app/
58
 
59
  # ── Entrypoint ────────────────────────────────────────────────────────────────
60
- RUN cat > /usr/local/bin/docker-entrypoint.sh << 'EOF'
61
- #!/bin/sh
62
- set -e
63
-
64
- # Usage: persist <image_path> <storage_path>
65
- # - First boot: moves image_path into persistent storage, then symlinks back
66
- # - Every boot: ensures symlink exists (in case image_path reappeared)
67
- persist() {
68
- SRC="$1" # original path in image e.g. /root/venv
69
- DEST="$2" # where to keep it in /data e.g. /data/persist/venv
70
-
71
- mkdir -p "$(dirname "$DEST")"
72
-
73
- if [ ! -e "$DEST" ]; then
74
- echo "[persist] First boot β€” moving $SRC β†’ $DEST"
75
- cp -a "$SRC" "$DEST"
76
- else
77
- echo "[persist] Reusing $DEST"
78
- fi
79
-
80
- # Remove original (could be a real dir from the image layer) and symlink
81
- rm -rf "$SRC"
82
- ln -sf "$DEST" "$SRC"
83
- echo "[persist] Symlinked $SRC β†’ $DEST"
84
- }
85
-
86
- # ── Directories to persist ────────────────────────────────────────────────────
87
- persist /root/venv /data/persist/venv
88
- persist /root/.cache /data/persist/cache
89
- persist /root/.npm-global /data/persist/npm-global
90
-
91
- exec "$@"
92
- EOF
93
- chmod +x /usr/local/bin/docker-entrypoint.sh
94
 
95
  # ── Runtime ───────────────────────────────────────────────────────────────────
96
  WORKDIR /data
 
37
  VIRTUAL_ENV=/root/venv \
38
  PIP_NO_CACHE_DIR=1
39
 
40
+ # ── Create Python venv ────────────────────────────────────────────────────────
41
  RUN python3 -m venv /root/venv && \
42
  /root/venv/bin/pip install --upgrade pip && \
43
  /root/venv/bin/pip install huggingface_hub
 
57
  COPY . /root/app/
58
 
59
  # ── Entrypoint ────────────────────────────────────────────────────────────────
60
+ RUN printf '%s\n' \
61
+ '#!/bin/sh' \
62
+ 'set -e' \
63
+ '' \
64
+ 'persist() {' \
65
+ ' SRC="$1"' \
66
+ ' DEST="$2"' \
67
+ ' mkdir -p "$(dirname "$DEST")"' \
68
+ ' if [ ! -e "$DEST" ]; then' \
69
+ ' echo "[persist] First boot -- moving $SRC to $DEST"' \
70
+ ' cp -a "$SRC" "$DEST"' \
71
+ ' else' \
72
+ ' echo "[persist] Reusing $DEST"' \
73
+ ' fi' \
74
+ ' rm -rf "$SRC"' \
75
+ ' ln -sf "$DEST" "$SRC"' \
76
+ ' echo "[persist] Symlinked $SRC to $DEST"' \
77
+ '}' \
78
+ '' \
79
+ 'persist /root/venv /data/persist/venv' \
80
+ 'persist /root/.cache /data/persist/cache' \
81
+ 'persist /root/.npm-global /data/persist/npm-global' \
82
+ '' \
83
+ 'exec "$@"' \
84
+ > /usr/local/bin/docker-entrypoint.sh && \
85
+ chmod +x /usr/local/bin/docker-entrypoint.sh
 
 
 
 
 
 
 
 
86
 
87
  # ── Runtime ───────────────────────────────────────────────────────────────────
88
  WORKDIR /data