This repository provides a multi-stage Docker build for PostgreSQL 16 with three extensions built from source, using the latest available versions:
- pgvecto.rs (default) - a high-performance alternative to pgvector
- Apache AGE - a graph DB extension for Postgres
- TimescaleDB - a time-series DB extension for Postgres
We also have an alternative build with pgvector proper. See below.
I realized we can achieve the same results with a multi-stage Docker build, so I deprecated the old code. It's still available in the legacy/
directory but I'm not planning on doing additional work on it.
From this directory, run:
docker build -t postgres-extensions .
docker run -d --name postgres-extensions \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
postgres-extensions
The first time the container starts, it will initialize the database, configure necessary parameters, and apply the extensions.
After the container is running, execute:
./test.sh [container_name]
If you omit [container_name]
, it defaults to postgres-extensions
. This script will:
- Wait for PostgreSQL to be ready.
- Create and load the required extensions.
- Run basic functionality tests for each extension.
All tests must pass for the setup to be valid.
Instead of using the pgvecto.rs package, you can build the official pgvector
extension from source using Dockerfile.pgvector
:
- Build:
docker build -f Dockerfile.pgvector -t postgres-extensions-pgvector .
- Run:
docker run -d --name pg-pgvector \ -e POSTGRES_PASSWORD=postgres \ -p 5433:5432 \ postgres-extensions-pgvector
- Test:
If you omit
./test-pgvector.sh [container_name]
[container_name]
, it defaults topg-pgvector
.