File size: 1,067 Bytes
373bb4f
 
 
 
6625f86
373bb4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -e

DATA_DIR="/data"
CODE_SERVER_ARGS=(--bind-addr 0.0.0.0:7860 --auth password --enable-proposed-api openai.chatgpt)

if [ -w "$DATA_DIR" ]; then
  echo "[entrypoint] Storage bucket detected at /data — persisting the entire home directory."

  PERSIST_HOME="$DATA_DIR/home"
  mkdir -p "$PERSIST_HOME"

  # First run only: seed the persistent home with whatever was baked into the
  # image (.bashrc, .profile, default dotfiles, etc.) without clobbering
  # anything already saved there from a previous session.
  if [ -z "$(ls -A "$PERSIST_HOME" 2>/dev/null)" ]; then
    cp -a "$HOME"/. "$PERSIST_HOME"/ 2>/dev/null || true
  fi

  export HOME="$PERSIST_HOME"
else
  echo "[entrypoint] No storage bucket attached at /data — running with EPHEMERAL storage."
  echo "[entrypoint] Everything in your home directory will be lost on restart."
  echo "[entrypoint] Attach a Storage Bucket at mount path /data in your Space settings to persist it."
fi

mkdir -p "$HOME/workspace"
cd "$HOME"

exec code-server "${CODE_SERVER_ARGS[@]}" "$HOME/workspace"