Add automatic shared dependencies for worktrees

Setup Conductor to automatically share node_modules and vendor directories
across all git worktrees to save disk space and speed up development.

Changes:
- Updated conductor-setup.sh to create symlinks to shared dependencies
- Added documentation to CLAUDE.md explaining the system
- Dependencies now stored in .shared-deps/ in main repository
- All worktrees use the same dependency versions automatically

Benefits:
- Saves hundreds of MBs to GBs of disk space
- No need to run npm install/composer install for each worktree
- Consistent dependency versions across all worktrees

Note: Add .shared-deps/ to .gitignore in the main repository

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai 2025-11-14 13:04:19 +01:00
parent ce4f8d02a2
commit ad148eca60
2 changed files with 67 additions and 1 deletions

View file

@ -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

View file

@ -1 +1,29 @@
cp $CONDUCTOR_ROOT_PATH/.env .env
#!/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"