A CLI tool for creating dedicated database containers for your git branches. Perfect for development workflows where each feature branch needs its own isolated database environment.
BranchSpawn automatically creates and manages PostgreSQL containers that are named after your git branches. It uses Docker Compose to spin up database containers, handles port conflicts, and manages container lifecycle based on your current git branch or a specified branch name.
Download the appropriate binary for your platform from the releases page.
curl -L https://github.com/owen-hope11/branchspawn/releases/download/<Version_Number>/branchspawn-ubuntu-latest -o branchspawn
chmod +x branchspawn
./branchspawnDue to macOS Gatekeeper restrictions on unsigned binaries, use curl to download and install:
curl -L https://github.com/owen-hope11/branchspawn/releases/download/<Version_Number>/branchspawn-macos-latest -o branchspawn
chmod +x branchspawn
./branchspawnInvoke-WebRequest -Uri https://github.com/owen-hope11/branchspawn/releases/download/<Version_Number>/branchspawn-windows-latest.exe -OutFile branchspawn.exe
.\branchspawn.exeTo use branchspawn from anywhere without ./, add it to your system's PATH:
# Move to a directory in your PATH
sudo mv branchspawn /usr/local/bin/
# Or add to user bin directory (create if it doesn't exist)
mkdir -p ~/.local/bin
mv branchspawn ~/.local/bin/
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc# Move to a directory in your PATH (e.g., C:\Program Files\branchspawn)
# Or add current directory to PATH environment variablegit clone https://github.com/owen-hope11/branchspawn.git
cd branchspawn
cargo build --release
./target/release/branchspawn- Docker installed and running
- A
compose.ymlfile in your project root (or specify path with-c) - Git repository
# Use current git branch to create/start container
branchspawn
# Specify a branch name
branchspawn -b feature/new-login
# Use custom compose file
branchspawn -c ./docker/postgres.yml
# Debug mode
branchspawn -v-b, --branch-name <NAME>: Specify branch name (defaults to current git branch)-c, --compose-file-path <PATH>: Path to compose file (defaults tocompose.yml)-d, --debug: Enable debug output (use multiple times for more verbosity)
- Branch Detection: Gets current git branch or uses specified branch name
- Container Naming: Creates container name like
feature-new-login-postgres - Port Conflict Check: Checks for existing containers using port 5432
- Container Management: Creates new container or starts existing one
- Environment Setup: Sets
CONTAINER_NAMEenvironment variable for compose file
services:
postgres:
image: postgres:15
container_name: ${CONTAINER_NAME}
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: myapp
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:MIT License - see LICENSE file for details.