https://github.com/ramxx/postgreswithextensions
Postgres container generator with extensions
https://github.com/ramxx/postgreswithextensions
docker generator postgres
Last synced: 5 months ago
JSON representation
Postgres container generator with extensions
- Host: GitHub
- URL: https://github.com/ramxx/postgreswithextensions
- Owner: RamXX
- License: apache-2.0
- Created: 2024-10-27T04:03:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-27T17:33:34.000Z (about 1 year ago)
- Last Synced: 2024-12-16T23:22:49.922Z (about 1 year ago)
- Topics: docker, generator, postgres
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PostgreSQL 16 with Extensions (Docker)
This repository provides a multi-stage Docker build for PostgreSQL 16 with three extensions built from source, using the latest available versions:
- [pgvecto.rs](https://github.com/tensorchord/pgvecto.rs) (default) - a high-performance alternative to [pgvector](https://github.com/pgvector/pgvector)
- [Apache AGE](https://github.com/apache/age) - a graph DB extension for Postgres
- [TimescaleDB](https://github.com/timescale/timescaledb) - a time-series DB extension for Postgres
We also have an alternative build with [pgvector](https://github.com/pgvector/pgvector) proper. See below.
# What happened with the Python builder?
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.
## Build the image
From this directory, run:
```bash
docker build -t postgres-extensions .
```
## Run the container
```bash
docker run -d --name postgres-extensions \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
postgres-extensions
```
By default `max_locks_per_transaction` is set to 256 on first initialization. To customize this value, pass the `POSTGRES_MAX_LOCKS_PER_TRANSACTION` environment variable. For example, to set it to 512:
```bash
docker run -d --name postgres-extensions \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_MAX_LOCKS_PER_TRANSACTION=512 \
-p 5432:5432 \
postgres-extensions
```
The first time the container starts, it will initialize the database, configure necessary parameters, and apply the extensions.
## Test the extensions
After the container is running, execute:
```bash
./test.sh [container_name]
```
If you omit `[container_name]`, it defaults to `postgres-extensions`. This script will:
1. Wait for PostgreSQL to be ready.
2. Create and load the required extensions.
3. Run basic functionality tests for each extension.
All tests must pass for the setup to be valid.
## Alternate Build: pgvector proper
Instead of using the pgvecto.rs package, you can build the official `pgvector` extension from source using `Dockerfile.pgvector`:
1. Build:
```bash
docker build -f Dockerfile.pgvector -t postgres-extensions-pgvector .
```
2. Run:
```bash
docker run -d --name pg-pgvector \
-e POSTGRES_PASSWORD=postgres \
-p 5433:5432 \
postgres-extensions-pgvector
```
3. Test:
```bash
./test-pgvector.sh [container_name]
```
If you omit `[container_name]`, it defaults to `pg-pgvector`.