From c42b47bb5643dfb12d5c537281d9c5e2cbb9cc2e Mon Sep 17 00:00:00 2001 From: Antigravity Developer Date: Fri, 20 Feb 2026 21:31:32 +0000 Subject: [PATCH] fix: persist Chrome profile data and settings across container restarts - Add explicit --user-data-dir flag to Chrome wrapper to ensure profile data is stored in the persistent home directory - Add cont-init-home.sh script to properly initialize home directory structure on container startup with correct permissions - Ensure Chrome config directory exists before Chrome starts - Bump chart version to 0.1.13 This fixes the issue where Chrome loses authentication and settings after pod restarts by explicitly managing where Chrome stores its profile data. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Dockerfile | 13 ++++++++++++- chart/Chart.yaml | 2 +- scripts/cont-init-home.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 scripts/cont-init-home.sh diff --git a/Dockerfile b/Dockerfile index 337f828..5a88405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,16 @@ RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearm # Chrome wrapper: adds flags required for running inside a Docker container. # xdg-open (used by Claude Code on Linux) respects $BROWSER, so pointing it # here ensures the OAuth popup works without manual --no-sandbox invocations. -RUN printf '#!/bin/bash\nexec /usr/bin/google-chrome-stable \\\n --no-sandbox \\\n --disable-dev-shm-usage \\\n --disable-gpu \\\n "$@"\n' > /usr/local/bin/google-chrome && \ +# Also explicitly sets user-data-dir to persist Chrome settings across restarts. +RUN printf '#!/bin/bash\n\ +# Ensure Chrome data directory exists with proper permissions\n\ +mkdir -p "$HOME/.config/google-chrome"\n\ +exec /usr/bin/google-chrome-stable \\\n\ + --no-sandbox \\\n\ + --disable-dev-shm-usage \\\n\ + --disable-gpu \\\n\ + --user-data-dir="$HOME/.config/google-chrome" \\\n\ + "$@"\n' > /usr/local/bin/google-chrome && \ chmod +x /usr/local/bin/google-chrome # Install Node.js (LTS version for Happy Coder) @@ -87,6 +96,8 @@ COPY --chmod=755 scripts/startapp.sh /startapp.sh COPY --chmod=755 scripts/init-repo.sh /usr/local/bin/init-repo # Fix app user shell after baseimage-gui creates it at runtime COPY --chmod=755 scripts/cont-init-user.sh /etc/cont-init.d/20-fix-user-shell.sh +# Initialize persistent home directory structure +COPY --chmod=755 scripts/cont-init-home.sh /etc/cont-init.d/21-init-home.sh COPY --chmod=755 scripts/cont-init-sshd.sh /etc/cont-init.d/25-start-sshd.sh # Set working directory diff --git a/chart/Chart.yaml b/chart/Chart.yaml index aee1716..f362211 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: devcontainer description: Antigravity Dev Container with Happy Coder AI assistant type: application -version: 0.1.12 +version: 0.1.13 appVersion: "latest" diff --git a/scripts/cont-init-home.sh b/scripts/cont-init-home.sh new file mode 100644 index 0000000..1ca8cc8 --- /dev/null +++ b/scripts/cont-init-home.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Initialize persistent home directory structure for the app user +# This ensures Chrome settings and SSH keys persist across pod restarts + +echo "=== Initializing persistent home directory ===" + +# Ensure the user home directory exists with proper ownership +if [ ! -d "/home/user" ]; then + echo "Creating /home/user directory..." + mkdir -p /home/user + chown app:app /home/user +fi + +# Ensure critical directories exist for persistent data +echo "Ensuring persistent directories exist..." +mkdir -p /home/user/.config +mkdir -p /home/user/.ssh +mkdir -p /home/user/.cache + +# Set proper ownership for all directories +chown -R app:app /home/user + +# Ensure SSH directory has proper permissions +chmod 700 /home/user/.ssh + +echo "Home directory initialization complete" \ No newline at end of file