soxogvv commited on
Commit
579cc67
Β·
verified Β·
1 Parent(s): 5fd98a9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -6
Dockerfile CHANGED
@@ -18,7 +18,7 @@ RUN apt-get update && \
18
  nano \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
- # ── Install bore (TCP tunnel β€” exposes SSH publicly for Termius) ──────────────
22
  RUN wget -q "https://github.com/ekzhang/bore/releases/download/v0.5.0/bore-v0.5.0-x86_64-unknown-linux-musl.tar.gz" \
23
  -O /tmp/bore.tar.gz && \
24
  tar -xzf /tmp/bore.tar.gz -C /usr/local/bin bore && \
@@ -37,7 +37,7 @@ ENV HOME=/root \
37
  VIRTUAL_ENV=/root/venv \
38
  PIP_NO_CACHE_DIR=1
39
 
40
- # ── Create a persistent 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
@@ -46,7 +46,7 @@ RUN python3 -m venv /root/venv && \
46
  RUN npm config set prefix /root/.npm-global && \
47
  npm install -g shellular
48
 
49
- # ── Create /data and ensure all shells land there ────────────────────────────
50
  RUN mkdir -p /data && \
51
  echo 'cd /data' >> /root/.bash_profile && \
52
  echo 'cd /data' >> /root/.bashrc
@@ -56,9 +56,41 @@ COPY package*.json /root/app/
56
  RUN cd /root/app && npm install --omit=dev
57
  COPY . /root/app/
58
 
59
- # ── Entrypoint β€” no hostname call (already baked into /etc/hostname) ──────────
60
- RUN printf '#!/bin/sh\nexec "$@"\n' > /usr/local/bin/docker-entrypoint.sh && \
61
- chmod +x /usr/local/bin/docker-entrypoint.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  # ── Runtime ───────────────────────────────────────────────────────────────────
64
  WORKDIR /data
 
18
  nano \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # ── Install bore ──────────────────────────────────────────────────────────────
22
  RUN wget -q "https://github.com/ekzhang/bore/releases/download/v0.5.0/bore-v0.5.0-x86_64-unknown-linux-musl.tar.gz" \
23
  -O /tmp/bore.tar.gz && \
24
  tar -xzf /tmp/bore.tar.gz -C /usr/local/bin bore && \
 
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
 
46
  RUN npm config set prefix /root/.npm-global && \
47
  npm install -g shellular
48
 
49
+ # ── Ensure /data exists and shells land there ─────────────────────────────────
50
  RUN mkdir -p /data && \
51
  echo 'cd /data' >> /root/.bash_profile && \
52
  echo 'cd /data' >> /root/.bashrc
 
56
  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