diff --git a/CLAUDE.md b/CLAUDE.md index b7c496e42..e8c040402 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,6 +10,44 @@ ## Project Overview Coolify is an open-source, self-hostable platform for deploying applications and managing servers - an alternative to Heroku/Netlify/Vercel. It's built with Laravel (PHP) and uses Docker for containerization. +## Git Worktree Shared Dependencies + +This repository uses git worktrees for parallel development with **automatic shared dependency setup** via Conductor. + +### How It Works + +The `conductor.json` setup script (`scripts/conductor-setup.sh`) automatically: +1. Creates a shared `.shared-deps/` directory in the main repository +2. Creates symlinks from `node_modules` and `vendor` to the shared location +3. This happens automatically when Conductor creates a new worktree + +### Benefits + +- **Save disk space**: Only one copy of dependencies across all worktrees +- **Faster setup**: No need to run `npm install` or `composer install` for each worktree +- **Consistent versions**: All worktrees use the same dependency versions +- **Auto-configured**: Handled by Conductor's setup script + +### Manual Setup (If Needed) + +If you need to set up symlinks manually or for non-Conductor worktrees: + +```bash +# From the worktree directory +SHARED_DEPS="../../.shared-deps" +mkdir -p "$SHARED_DEPS/node_modules" "$SHARED_DEPS/vendor" +rm -rf node_modules vendor +ln -sf "$SHARED_DEPS/node_modules" node_modules +ln -sf "$SHARED_DEPS/vendor" vendor +``` + +### Important Notes + +- Dependencies are shared at `$CONDUCTOR_ROOT_PATH/.shared-deps/` +- Run `npm install` or `composer install` from any worktree to update all +- Ensure `.shared-deps/` is in `.gitignore` (should already be there) +- If different branches need different dependency versions, this won't work - remove symlinks and use separate directories + ## Development Commands ### Frontend Development diff --git a/scripts/conductor-setup.sh b/scripts/conductor-setup.sh index 7712f88be..963c8e808 100755 --- a/scripts/conductor-setup.sh +++ b/scripts/conductor-setup.sh @@ -1 +1,29 @@ -cp $CONDUCTOR_ROOT_PATH/.env .env \ No newline at end of file +#!/bin/bash +set -e + +# Copy .env file +cp $CONDUCTOR_ROOT_PATH/.env .env + +# Setup shared dependencies via symlinks +echo "Setting up shared node_modules and vendor directories..." + +# Create shared-deps directory in main repository if it doesn't exist +SHARED_DEPS="$CONDUCTOR_ROOT_PATH/.shared-deps" +mkdir -p "$SHARED_DEPS/node_modules" +mkdir -p "$SHARED_DEPS/vendor" + +# Remove existing directories if they exist and are not symlinks +[ -d "node_modules" ] && [ ! -L "node_modules" ] && rm -rf node_modules +[ -d "vendor" ] && [ ! -L "vendor" ] && rm -rf vendor + +# Calculate relative path from worktree to shared deps +WORKTREE_PATH=$(pwd) +RELATIVE_PATH=$(python3 -c "import os.path; print(os.path.relpath('$SHARED_DEPS', '$WORKTREE_PATH'))") + +# Create symlinks +ln -sf "$RELATIVE_PATH/node_modules" node_modules +ln -sf "$RELATIVE_PATH/vendor" vendor + +echo "✓ Shared dependencies linked successfully" +echo " node_modules -> $RELATIVE_PATH/node_modules" +echo " vendor -> $RELATIVE_PATH/vendor" \ No newline at end of file