Tagline: "Forge your PostgreSQL instances with precision"
PgForge is a modern, cross-platform CLI tool built with Bun that simplifies the creation, management, and orchestration of multiple PostgreSQL instances on a single machine.
- Instance-First Approach: Manage multiple PostgreSQL instances, not just versions
- YAML Configuration: Declarative configuration as code
- Templates: Pre-built templates for development, production, and testing
- Process Management: Start, stop, restart instances with ease
- Built-in Validation: Configuration validation and error checking
- Modern CLI: Rich, colorful interface with progress indicators
Before installing PgForge, ensure you have PostgreSQL installed on your system:
sudo apt update sudo apt install postgresql postgresql-contrib
# Using Homebrew brew install postgresql@15 brew services start postgresql@15 # Or using PostgreSQL.app # Download from https://postgresapp.com/
-
Download the appropriate binary from the latest release:
- Linux (x64):
pgforge-linux-x64 - macOS (Intel):
pgforge-darwin-x64 - macOS (Apple Silicon):
pgforge-darwin-arm64
- Linux (x64):
-
Make it executable and install:
# For Linux chmod +x pgforge-linux-x64 sudo mv pgforge-linux-x64 /usr/local/bin/pgforge # For macOS (Intel) chmod +x pgforge-darwin-x64 sudo mv pgforge-darwin-x64 /usr/local/bin/pgforge # For macOS (Apple Silicon) chmod +x pgforge-darwin-arm64 sudo mv pgforge-darwin-arm64 /usr/local/bin/pgforge
-
Verify installation:
pgforge --version
curl -fsSL https://raw.githubusercontent.com/xar/pgforge/main/install.sh | bashAfter installation, follow these steps to create your first PostgreSQL instance:
pgforge init
This creates the configuration directory (~/.pgforge/) and sets up default templates.
# Create a basic development instance pgforge create mydb # Or use a template for specific use cases pgforge create devdb --template development pgforge create proddb --template production
# Start the instance pgforge start mydb # Get connection information pgforge connection-string mydb # Output: postgresql://postgres@localhost:5432/mydb # Connect using psql psql $(pgforge connection-string mydb)
# List all instances pgforge list # Show detailed instance information pgforge show mydb # Stop an instance pgforge stop mydb # Restart an instance pgforge restart mydb
| Command | Description |
|---|---|
pgforge init |
Initialize PgForge configuration |
pgforge create <name> |
Create a new PostgreSQL instance |
pgforge list |
List all instances |
pgforge start <name> |
Start an instance |
pgforge stop <name> |
Stop an instance |
pgforge restart <name> |
Restart an instance |
pgforge show <name> |
Show instance details |
pgforge remove <name> |
Remove an instance |
pgforge status [name] |
Show status information |
pgforge connection-string <name> |
Get connection information |
Use templates to quickly create instances with predefined configurations:
# Development instance (minimal security, no backups) pgforge create devdb --template development # Production instance (SSL, backups, optimized settings) pgforge create proddb --template production # Testing instance (lightweight, no persistence) pgforge create testdb --template testing
PgForge uses YAML configuration files stored in ~/.pgforge/:
~/.pgforge/config.yaml- Global configuration~/.pgforge/instances/*.yaml- Instance configurations
apiVersion: v1 kind: PostgreSQLInstance metadata: name: myapp-db labels: environment: production spec: version: "15.3" network: port: 5433 bindAddress: "127.0.0.1" maxConnections: 200 storage: dataDirectory: "/var/lib/postgresql/pgforge/myapp-db" logDirectory: "/var/log/postgresql/pgforge/myapp-db" database: name: myapp_production owner: myapp_user encoding: UTF8 security: ssl: enabled: true authentication: method: md5 allowedHosts: - "127.0.0.1/32"
Note: This section is for contributors who want to build PgForge from source. End users should use the pre-built binaries instead.
- Bun 1.0+
- PostgreSQL 13+
- Ubuntu 18.04+ / macOS 12+
# Clone the repository git clone https://github.com/xar/pgforge.git cd pgforge # Install dependencies bun install # Run in development mode bun run --watch index.ts # Build standalone binary bun build index.ts --compile --outfile pgforge
pgforge/
βββ src/
β βββ config/ # Configuration management
β βββ instance/ # Instance management
β βββ utils/ # Utilities and helpers
βββ ai/
β βββ specification.md # Full project specification
βββ index.ts # Main CLI entry point
βββ install.sh # Ubuntu installation script
This is the first version (v0.1.0) focusing on core functionality:
- Basic instance creation and management
- YAML configuration schema
- Start/stop/restart operations
- Template system
- Installation scripts
- Advanced monitoring and health checks
- Backup and recovery system
- Performance auto-tuning
- CLI improvements and UX enhancements
- Replication and clustering
- Advanced security features
- API and webhook support
- CI/CD integrations
We welcome contributions! Please see our specification document for the full vision and roadmap.
MIT License - see LICENSE file for details.
If you get "PostgreSQL not found" errors:
# Check if PostgreSQL is installed which psql # Ubuntu/Debian: Install PostgreSQL sudo apt install postgresql postgresql-contrib # macOS: Install via Homebrew brew install postgresql@15
If you get permission errors:
# Make sure the binary is executable chmod +x /usr/local/bin/pgforge # Check if /usr/local/bin is in your PATH echo $PATH
If the default port (5432) is already in use:
# Create instance with custom port pgforge create mydb --port 5433 # Or edit the instance configuration pgforge show mydb --config
To completely remove PgForge:
# Stop all instances pgforge list --format json | jq -r '.[].name' | xargs -I {} pgforge stop {} # Remove binary sudo rm /usr/local/bin/pgforge # Remove configuration (optional - this deletes all your instance configs) rm -rf ~/.pgforge
- Issues: Report bugs or request features
- Discussions: Community discussions and Q&A
- Documentation: Full project specification
When reporting issues, please include:
- Your operating system and version
- PgForge version (
pgforge --version) - PostgreSQL version (
psql --version) - Full error message or command output
Built with β€οΈ using Bun and TypeScript