Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This repository builds a custom PostgreSQL 15.13 Docker image with pre-installed
The custom Postgres image includes:
- **pgvector** (v0.7.4) - Vector similarity search for embeddings
- **pg_graphql** (v1.5.11) - GraphQL API generation from PostgreSQL schemas
- **pg_net** (v0.14.0) - Async HTTP/HTTPS requests from PostgreSQL
- **TimescaleDB 2** - Time-series database capabilities
- **PostGIS 3** - Spatial database support
- **pg_cron** - Job scheduling within PostgreSQL
Expand Down Expand Up @@ -68,8 +69,9 @@ git push origin v1.0.0
### Extension Version Management

When updating extension versions:
- **pgvector**: Update git tag in line 28 of [postgres/Dockerfile](postgres/Dockerfile#L28)
- **pg_graphql**: Update git checkout in line 44 of [postgres/Dockerfile](postgres/Dockerfile#L44)
- **pgvector**: Update git tag in line 19 of [postgres/Dockerfile](postgres/Dockerfile#L19)
- **pg_graphql**: Update git checkout in line 35 of [postgres/Dockerfile](postgres/Dockerfile#L35)
- **pg_net**: Update git checkout in line 45 of [postgres/Dockerfile](postgres/Dockerfile#L45)
- **TimescaleDB, PostGIS, pg_cron, pg_http**: Managed via apt packages

### Build Dependencies
Expand All @@ -79,6 +81,11 @@ When updating extension versions:
- cargo-pgrx v0.12.9 (must match pg_graphql compatibility)
- PostgreSQL server development files

- **pg_net** requires:
- Rust toolchain (installed via rustup)
- cargo-pgrx v0.12.9 (shared with pg_graphql)
- libcurl4 runtime dependency

- **pgvector** requires:
- GCC compiler
- PostgreSQL server development files
Expand All @@ -94,11 +101,12 @@ docker exec -it <container_id> psql -U postgres

# Inside psql, check available extensions
SELECT * FROM pg_available_extensions
WHERE name IN ('vector', 'pg_graphql', 'timescaledb', 'postgis', 'pg_cron', 'http');
WHERE name IN ('vector', 'pg_graphql', 'pg_net', 'timescaledb', 'postgis', 'pg_cron', 'http');

# Enable extensions
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS pg_graphql;
CREATE EXTENSION IF NOT EXISTS pg_net;
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS pg_cron;
Expand Down
19 changes: 18 additions & 1 deletion postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y \
RUN cd /tmp && \
git clone --branch v0.7.4 https://github.com/pgvector/pgvector.git && \
cd pgvector && \
make PG_CONFIG=/usr/lib/postgresql/15/bin/pg_config && \
make PG_CONFIG=/usr/lib/postgresql/15/bin/pg_config OPTFLAGS="" && \
make install PG_CONFIG=/usr/lib/postgresql/15/bin/pg_config && \
cd / && \
rm -rf /tmp/pgvector
Expand All @@ -38,6 +38,19 @@ RUN cd /tmp && \
cd / && \
rm -rf /tmp/pg_graphql

# Build pg_net (async HTTP requests) - C extension using libcurl
# Note: v0.14.0 has curl type warnings, disable -Werror for compatibility with newer compilers
RUN apt-get update && apt-get install -y libcurl4-openssl-dev && \
cd /tmp && \
git clone https://github.com/supabase/pg_net.git && \
cd pg_net && \
git checkout v0.14.0 && \
make PG_CONFIG=/usr/lib/postgresql/15/bin/pg_config CFLAGS="-Wno-error" && \
make install PG_CONFIG=/usr/lib/postgresql/15/bin/pg_config && \
cd / && \
rm -rf /tmp/pg_net && \
rm -rf /var/lib/apt/lists/*

# Final stage - clean runtime image
FROM postgres:15.13

Expand All @@ -61,13 +74,17 @@ RUN apt-get update && apt-get install -y \
postgresql-15-postgis-3 \
postgis \
timescaledb-2-postgresql-15 \
libcurl4 \
&& rm -rf /var/lib/apt/lists/*

# Copy compiled extensions from builder stage
COPY --from=builder /usr/lib/postgresql/15/lib/vector.so /usr/lib/postgresql/15/lib/
COPY --from=builder /usr/share/postgresql/15/extension/vector* /usr/share/postgresql/15/extension/
COPY --from=builder /usr/lib/postgresql/15/lib/pg_graphql.so /usr/lib/postgresql/15/lib/
COPY --from=builder /usr/share/postgresql/15/extension/pg_graphql* /usr/share/postgresql/15/extension/
# pg_net may create versioned .so files, copy all matching patterns
COPY --from=builder /usr/lib/postgresql/15/lib/pg_net*.so /usr/lib/postgresql/15/lib/
COPY --from=builder /usr/share/postgresql/15/extension/pg_net* /usr/share/postgresql/15/extension/

# Clean up unnecessary packages
RUN apt-get purge -y lsb-release curl gnupg && \
Expand Down
Loading