1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Multi-stage Dockerfile for ruvector-postgres extension
# Builds the extension and creates a PostgreSQL image with it installed
# Build stage
FROM rust:1.75-slim-bookworm AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
pkg-config \
postgresql-server-dev-16 \
postgresql-16 \
clang \
libclang-dev \
&& rm -rf /var/lib/apt/lists/*
# Install cargo-pgrx
RUN cargo install cargo-pgrx --version 0.12.0 --locked
# Set up workspace
WORKDIR /build
# Copy only Cargo files first for better layer caching
COPY Cargo.toml Cargo.lock ./
COPY crates/ruvector-postgres/Cargo.toml ./crates/ruvector-postgres/
# Copy source code
COPY crates/ruvector-postgres ./crates/ruvector-postgres/
# Initialize pgrx
RUN cd crates/ruvector-postgres && \
cargo pgrx init --pg16=/usr/lib/postgresql/16/bin/pg_config
# Build the extension with all features
RUN cd crates/ruvector-postgres && \
cargo pgrx package --features pg16,index-all,quant-all --release
# Runtime stage
FROM postgres:16-bookworm
# Labels
LABEL maintainer="ruvector team"
LABEL description="PostgreSQL with ruvector extension - high-performance vector similarity search"
LABEL version="0.1.0"
# Copy the built extension from builder
COPY --from=builder /build/target/release/ruvector-postgres-pg16/usr/share/postgresql/16/extension/* \
/usr/share/postgresql/16/extension/
COPY --from=builder /build/target/release/ruvector-postgres-pg16/usr/lib/postgresql/16/lib/* \
/usr/lib/postgresql/16/lib/
# Copy SQL files and control file
COPY --from=builder /build/crates/ruvector-postgres/ruvector.control \
/usr/share/postgresql/16/extension/
COPY --from=builder /build/crates/ruvector-postgres/sql/*.sql \
/usr/share/postgresql/16/extension/
# Set environment variables
ENV POSTGRES_DB=postgres
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=postgres
# Add initialization script to create extension
RUN mkdir -p /docker-entrypoint-initdb.d
RUN echo "CREATE EXTENSION IF NOT EXISTS ruvector;" > /docker-entrypoint-initdb.d/01-ruvector.sql
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD pg_isready -U postgres || exit 1
# Expose PostgreSQL port
EXPOSE 5432
# Use the default PostgreSQL entrypoint
CMD ["postgres"]