fix: pin Antigravity user data to home PVC to survive pod restarts #22

Merged
cpfarhood merged 2 commits from fix/antigravity-userdata-persistence into main 2026-02-20 20:46:07 +00:00
3 changed files with 29 additions and 6 deletions
+1 -1
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: devcontainer name: devcontainer
description: Antigravity Dev Container with Happy Coder AI assistant description: Antigravity Dev Container with Happy Coder AI assistant
type: application type: application
version: 0.1.10 version: 0.1.11
appVersion: "latest" appVersion: "latest"
+21 -3
View File
@@ -5,12 +5,30 @@
echo "=== SSH enabled: starting sshd ===" echo "=== SSH enabled: starting sshd ==="
# Generate host keys if missing (first boot or ephemeral /etc/ssh) HOME_DIR="/home/user"
ssh-keygen -A 2>/dev/null || true HOST_KEY_STORE="$HOME_DIR/.ssh/host_keys"
# Persist host keys on the home PVC so clients don't see a "host key
# changed" warning after pod restarts.
if [ -d "$HOST_KEY_STORE" ] && [ -n "$(ls "$HOST_KEY_STORE"/ssh_host_* 2>/dev/null)" ]; then
# Restore previously generated host keys
echo "Restoring SSH host keys from PVC..."
cp "$HOST_KEY_STORE"/ssh_host_* /etc/ssh/
chmod 600 /etc/ssh/ssh_host_*_key
chmod 644 /etc/ssh/ssh_host_*_key.pub
else
# First boot: generate and save host keys to PVC
echo "Generating SSH host keys (first boot)..."
ssh-keygen -A 2>/dev/null || true
mkdir -p "$HOST_KEY_STORE"
cp /etc/ssh/ssh_host_* "$HOST_KEY_STORE/"
chmod 700 "$HOST_KEY_STORE"
chown -R 1000:1000 "$HOST_KEY_STORE"
echo "SSH host keys saved to PVC."
fi
# Populate authorized_keys from env var (injected via Kubernetes secret) # Populate authorized_keys from env var (injected via Kubernetes secret)
if [ -n "$SSH_AUTHORIZED_KEYS" ]; then if [ -n "$SSH_AUTHORIZED_KEYS" ]; then
HOME_DIR="/home/user"
mkdir -p "$HOME_DIR/.ssh" mkdir -p "$HOME_DIR/.ssh"
chmod 700 "$HOME_DIR/.ssh" chmod 700 "$HOME_DIR/.ssh"
printf '%s\n' "$SSH_AUTHORIZED_KEYS" > "$HOME_DIR/.ssh/authorized_keys" printf '%s\n' "$SSH_AUTHORIZED_KEYS" > "$HOME_DIR/.ssh/authorized_keys"
+7 -2
View File
@@ -21,8 +21,13 @@ echo "Workspace: $WORKSPACE_DIR"
case "$IDE" in case "$IDE" in
antigravity) antigravity)
echo "Opening Google Antigravity in: $WORKSPACE_DIR" echo "Opening Google Antigravity in: $WORKSPACE_DIR"
# --no-sandbox is required for Electron apps in Docker (no kernel sandbox available) # --no-sandbox is required for Electron apps in Docker (no kernel sandbox available).
exec antigravity --no-sandbox --new-window --wait "$WORKSPACE_DIR" # Explicit --user-data-dir and --extensions-dir pin config to the home PVC so
# settings and the setup wizard state survive pod restarts.
exec antigravity --no-sandbox \
--user-data-dir "$HOME/.config/antigravity" \
--extensions-dir "$HOME/.antigravity/extensions" \
--new-window --wait "$WORKSPACE_DIR"
;; ;;
none) none)
echo "IDE=none: no IDE launched, keeping container alive." echo "IDE=none: no IDE launched, keeping container alive."