-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.pgvector
More file actions
57 lines (44 loc) · 2.08 KB
/
Dockerfile.pgvector
File metadata and controls
57 lines (44 loc) · 2.08 KB
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
# Multi-stage Docker build for PostgreSQL 17 with Apache AGE, TimescaleDB, and pgvector proper
######## Stage 1: Build extensions ########
FROM postgres:17 AS builder
ENV PG_MAJOR=17
# Install build dependencies (including CA certificates for HTTPS and git)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates build-essential cmake flex bison libreadline-dev zlib1g-dev \
curl git gnupg jq postgresql-server-dev-$PG_MAJOR \
&& rm -rf /var/lib/apt/lists/*
# Build Apache AGE
RUN git clone --branch PG17 --depth 1 https://github.com/apache/age.git /tmp/age \
&& cd /tmp/age \
&& make PG_CONFIG=/usr/bin/pg_config \
&& make install PG_CONFIG=/usr/bin/pg_config
# Build TimescaleDB
RUN git clone --depth 1 https://github.com/timescale/timescaledb.git /tmp/timescaledb \
&& cd /tmp/timescaledb \
&& ./bootstrap -DPG_CONFIG=/usr/bin/pg_config -DAPACHE_ONLY=1 \
&& cd build \
&& make \
&& make install
# Build pgvector extension from source
RUN git clone --depth 1 https://github.com/pgvector/pgvector.git /tmp/pgvector \
&& cd /tmp/pgvector \
&& make PG_CONFIG=/usr/bin/pg_config \
&& make install PG_CONFIG=/usr/bin/pg_config
######## Stage 2: Final image ########
FROM postgres:17
ENV PG_MAJOR=17
# Copy built extensions and libraries
COPY --from=builder /usr/lib/postgresql/$PG_MAJOR/lib/ /usr/lib/postgresql/$PG_MAJOR/lib/
# Copy extension control and SQL files
COPY --from=builder /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/
# Create plugin directory for Apache AGE and symlink the plugin
RUN mkdir -p /usr/lib/postgresql/$PG_MAJOR/lib/plugins && \
ln -s /usr/lib/postgresql/$PG_MAJOR/lib/age.so /usr/lib/postgresql/$PG_MAJOR/lib/plugins/age.so
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates jq wget \
&& rm -rf /var/lib/apt/lists/*
# Add initialization script to configure PostgreSQL (pgvector variant)
COPY initdb/99-config-pgvector.sh /docker-entrypoint-initdb.d/99-config.sh
RUN chmod +x /docker-entrypoint-initdb.d/99-config.sh
EXPOSE 5432