Skip to content

postgres-pm/pgpm

Repository files navigation

Postgres.pm

Postgres.pm (aka pgpm) is a streamlined package manager designed to simplify the process of building and distributing Postgres extensions and packages.

Key objectives

Platform independence

Postgres.pm is designed to deliver Postgres extensions in native packaging (such as RPM, DEB, OCI images, etc.) to support the broad variety of usage patterns.

Note

Early release is targeting RHEL-based distributions using official PGDG Postgres distributions with other options coming up.

Low-effort package maintenance

Postgres.pm embraces the concept of inferences: based on given information, it'll figure out how to build the package if it fits into a set of pre-defined rules.

New versions are automatically picked up and recognized.

Package definition can be as simple as this – with no routine maintenace on new releases:

class Pgvector < Pgpm::Package
  github "pgvector/pgvector"
end
Package definition flexibility

Packages definitions are defined in Ruby, allowing for near-infinite flexibility of their definition when necessary.

This allows us to accomodate non-standard build and installation procedures with ease.


Current Status

We are preparing to start publishing RPM packages publicly soon. It's possible to build included packages manually.

Development

To build the packages, use the exe/pgpm script.

Example:

./exe/pgpm build pgvector

pgpm build command

Usage:
  pgpm build PACKAGES...

Arguments:
  PACKAGES  # Package names (can include version with @, e.g., [email protected])

Options:
  --pkgdir=VALUE    # Directory to load packages from (default: "packages" if directory exists)
  --os=VALUE        # OS name (default: auto-detected)
  --arch=VALUE      # Target architecture (default: host architecture)
  --pgdist=VALUE    # Target Postgres distribution (default: "pgdg")
  --pgver=VALUE     # Target Postgres version (default: latest supported version)

Examples:

# Build specific version
pgpm build [email protected]

# Build for specific Postgres version
pgpm build pgvector --pgver=15

# Build multiple packages
pgpm build pgvector pg_cron

# Build from custom package directory
pgpm build pgvector --pkgdir=custom/packages

Running pgpm build command via Official Docker Image

Pull the official Docker image:

docker pull ghcr.io/postgres-pm/pgpm:latest

You can use the following command to build the packages:

docker run --rm -it ghcr.io/postgres-pm/pgpm:latest pgpm build pgvector

If using the development version (pgpm-dev stage), you can mount the current directory to the container:

docker run --rm -it -v $(pwd):/pgpm ghcr.io/postgres-pm/pgpm:latest pgpm build pgvector

Building the Docker Image

To build the Docker image, use the following command:

# Build and load the image into local Docker daemon
docker buildx build --load --allow security.insecure -t pgpm:local .

To use insecure builder, you can run the following commands:

docker buildx create --name insecure-builder --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 --buildkitd-flags '--allow-insecure-entitlement security.insecure'
docker buildx use insecure-builder
env DOCKER_BUILDKIT=1 docker build --allow security.insecure -t pgpm:local .

Later, you can use the builder by running:

env DOCKER_BUILDKIT=1 docker build --builder=insecure-builder --allow security.insecure -t pgpm:local .

To run the image, use the following command:

# If using the base pgpm image
docker run --rm -it pgpm:local pgpm build pgvector

# If using the development version (pgpm-dev stage)
docker run --rm -it -v $(pwd):/pgpm pgpm:local ./exe/pgpm build pgvector

To remove the builder, run the following command:

docker buildx rm insecure-builder

To remove the image, run the following command:

docker rmi pgpm:local
docker rmi ghcr.io/postgres-pm/pgpm:latest