Vscode / entrypoint.sh
Hemifield's picture
Update entrypoint.sh
6625f86 verified
Raw
History Blame Contribute Delete
1.07 kB
#!/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"