pgbox

command module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: GPL-3.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pgbox 🐘📦

pgbox is a CLI tool for running PostgreSQL in Docker with your choice of extensions.

It is designed for experimentation and prototyping, making it easy to test extensions before using them in a project.

Why pgbox?
  • Quick setup: Spin up PostgreSQL with any set of extensions in seconds
  • Easy experimentation: Test extensions locally before adding them to your stack
  • Export to Docker: Export Docker Compose files when ready for your project
  • 150+ extensions supported: From apt.postgresql.org

Think of pgbox as a PostgreSQL sandbox — a safe place to explore 150+ extensions without manual installs or risking your development database.

Installation

Download Pre-built Binary

Download the latest release for your platform from GitHub Releases.

Using the install script
curl -sSL https://raw.githubusercontent.com/ahacop/pgbox/main/install.sh | sh
Manual download
  1. Download the appropriate archive for your platform from releases
  2. Extract and move to your PATH:
tar -xzf pgbox_*_Linux_x86_64.tar.gz
sudo mv pgbox /usr/local/bin/
Using Go
go install github.com/ahacop/pgbox@latest
Using Nix Flake
# Run directly without installation
nix run github:ahacop/pgbox -- --help

# Start with specific extensions
nix run github:ahacop/pgbox -- up --ext pgvector,postgis
Build from Source
git clone https://github.com/ahacop/pgbox
cd pgbox
make build

# Optional: Install to GOPATH/bin
make install

Usage

Quick Start
# Start PostgreSQL with default settings (no extensions)
./pgbox up

# Start PostgreSQL with specific extensions
./pgbox up --ext pgvector,hypopg

# List available extensions
./pgbox list-extensions

# Connect to running PostgreSQL instance
./pgbox psql

# Stop and remove containers
./pgbox down
Common Commands
Starting PostgreSQL
# Start with default settings (PostgreSQL 18, port 5432)
./pgbox up

# Start with specific extensions
./pgbox up --ext pgvector,postgis,pg_trgm

# Start with custom PostgreSQL version
./pgbox up --pg-version 16

# Start on a different port
./pgbox up --port 5433

# Start with custom credentials
./pgbox up --user myuser --password mypass --database mydb

# Start without detaching (see logs in foreground)
./pgbox up --detach=false

# Start with custom container name
./pgbox up --name my-postgres-dev
Managing Containers
# Check status of running containers
./pgbox status

# View container logs
./pgbox logs

# Follow logs in real-time
./pgbox logs --follow

# Restart container
./pgbox restart

# Stop container (keeps data)
./pgbox down

# Stop and remove container with volumes
./pgbox down --volumes

# Clean up all pgbox containers and volumes
./pgbox clean
Working with PostgreSQL
# Connect with psql
./pgbox psql

# Connect to specific container by name
./pgbox psql --name my-postgres-dev

# Pass arguments to psql
./pgbox psql -- -c "SELECT version();"

# List available extensions
./pgbox list-extensions

# Search for specific extensions
./pgbox list-extensions | grep vector
Exporting for your project
# Export Docker configuration to directory
./pgbox export ./my-postgres

# Export with specific version and extensions
./pgbox export ./my-postgres -v 16 --ext pgvector,hypopg

# Export with custom port
./pgbox export ./my-postgres -p 5433

# Generated files:
# - Dockerfile: Custom image with extensions
# - docker-compose.yml: Complete Docker Compose setup with required configurations
# - init.sql: SQL script to create extensions
# - postgresql.conf (if needed): PostgreSQL configuration for extensions requiring preload

Development

Prerequisites
  • Go 1.24+
  • Docker
  • Optional: golangci-lint for linting
Building
# Build the binary
make build

# Run tests
make test

# Run all checks (format, vet, test)
make check

# Clean build artifacts
make clean
Testing
# Run tests
make test

# Run tests with coverage
make test-coverage

# Test export functionality
make export EXTS=pgvector,pg_cron PG_VERSION=18

# Run PostgreSQL with extensions
make run EXTS=pgvector,pg_cron PORT=5432

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Release Process (Maintainers)

Creating a Release
  1. Ensure all changes are committed and pushed

    git status
    git push origin main
    
  2. Run the release preparation script

    ./scripts/prepare-release.sh v0.3.0
    

    This script will:

    • Update the VERSION file
    • Update the vendorHash in flake.nix
    • Run tests
    • Create a git commit and tag
  3. Push the commit and tag

    git push origin main
    git push origin v0.3.0
    
  4. GitHub Actions will automatically:

    • Run tests and quality checks
    • Build binaries for Linux and macOS (amd64/arm64)
    • Create a GitHub release with pre-built binaries and checksums
  5. Verify the release

    ./scripts/test-release.sh --tag v0.3.0
    
Testing Releases
# Test latest release (dry-run, no installation)
./scripts/test-release.sh --dry-run

# Test specific release with full installation
./scripts/test-release.sh --tag v0.2.2

# Test local release build
make release-snapshot

License

GPL-3.0

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
docker
Package docker provides Docker container operations
Package docker provides Docker container operations
extensions
Package extensions provides the extension catalog for pgbox.
Package extensions provides the extension catalog for pgbox.
model
Package model provides in-memory representations of Docker artifacts
Package model provides in-memory representations of Docker artifacts
orchestrator
Package orchestrator contains the business logic for pgbox commands.
Package orchestrator contains the business logic for pgbox commands.
render
Package render converts in-memory models to Docker artifact files
Package render converts in-memory models to Docker artifact files
util
Package util provides shared utility functions for pgbox.
Package util provides shared utility functions for pgbox.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址