c7a7e8bd12
Add containerized GUI development environment featuring: - Antigravity IDE (VSCode) accessible via web browser - Happy Coder AI assistant integration - Automatic GitHub repository cloning on startup - Persistent user home directory (ReadWriteMany PVC) - Secure non-root execution as user claude (UID 1000) Components: - Dockerfile based on jlesage/baseimage-gui - Startup scripts for repo initialization and app launch - Kubernetes manifests (StatefulSet, ConfigMap, Secrets) - Makefile for build and deployment automation - Comprehensive documentation Features: - Web-based VNC interface (port 5800) - GitHub token authentication for private repos - Happy Coder runs as background service in workspace - CephFS storage for persistent home directory - Configurable display resolution and security Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
79 lines
2.5 KiB
Bash
79 lines
2.5 KiB
Bash
#!/bin/bash
|
|
# Initialize repository and start Happy Coder
|
|
set -e
|
|
|
|
echo "=== Repository Initialization ==="
|
|
|
|
# Check if GITHUB_REPO is set
|
|
if [ -z "$GITHUB_REPO" ]; then
|
|
echo "GITHUB_REPO not set, skipping repository clone"
|
|
WORKSPACE_DIR="/workspace/default"
|
|
mkdir -p "$WORKSPACE_DIR"
|
|
else
|
|
# Parse repo name from URL
|
|
REPO_NAME=$(basename "$GITHUB_REPO" .git)
|
|
WORKSPACE_DIR="/workspace/$REPO_NAME"
|
|
|
|
echo "Repository: $GITHUB_REPO"
|
|
echo "Target directory: $WORKSPACE_DIR"
|
|
|
|
# Check if repo already exists
|
|
if [ -d "$WORKSPACE_DIR/.git" ]; then
|
|
echo "Repository already exists, pulling latest changes..."
|
|
cd "$WORKSPACE_DIR"
|
|
|
|
# Configure git to use token if provided
|
|
if [ -n "$GITHUB_TOKEN" ]; then
|
|
git config credential.helper store
|
|
echo "https://oauth2:${GITHUB_TOKEN}@github.com" > /home/claude/.git-credentials
|
|
chmod 600 /home/claude/.git-credentials
|
|
fi
|
|
|
|
git pull || echo "Pull failed, continuing anyway..."
|
|
else
|
|
echo "Cloning repository..."
|
|
mkdir -p "$(dirname "$WORKSPACE_DIR")"
|
|
|
|
# Clone with token if provided
|
|
if [ -n "$GITHUB_TOKEN" ]; then
|
|
# Replace https://github.com/ with https://oauth2:token@github.com/
|
|
CLONE_URL=$(echo "$GITHUB_REPO" | sed "s|https://github.com/|https://oauth2:${GITHUB_TOKEN}@github.com/|")
|
|
git clone "$CLONE_URL" "$WORKSPACE_DIR"
|
|
|
|
# Configure credentials for future use
|
|
git config --global credential.helper store
|
|
echo "https://oauth2:${GITHUB_TOKEN}@github.com" > /home/claude/.git-credentials
|
|
chmod 600 /home/claude/.git-credentials
|
|
else
|
|
git clone "$GITHUB_REPO" "$WORKSPACE_DIR"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Set ownership
|
|
chown -R claude:claude "$WORKSPACE_DIR"
|
|
chown -R claude:claude /home/claude
|
|
|
|
# Start Happy Coder in background as claude user
|
|
echo "Starting Happy Coder..."
|
|
cd "$WORKSPACE_DIR"
|
|
|
|
# Create Happy Coder log file
|
|
HAPPY_LOG="/tmp/happy-coder.log"
|
|
touch "$HAPPY_LOG"
|
|
chown claude:claude "$HAPPY_LOG"
|
|
|
|
# Start Happy Coder as claude user
|
|
sudo -u claude bash -c "cd '$WORKSPACE_DIR' && happy-coder > '$HAPPY_LOG' 2>&1 &"
|
|
|
|
# Save PID for monitoring
|
|
echo $! > /tmp/happy-coder.pid
|
|
|
|
echo "Happy Coder started (PID: $(cat /tmp/happy-coder.pid))"
|
|
echo "Logs available at: $HAPPY_LOG"
|
|
|
|
# Export workspace directory for startapp.sh
|
|
echo "$WORKSPACE_DIR" > /tmp/workspace-dir
|
|
|
|
echo "=== Initialization Complete ==="
|