Skip to content

Commit 3fbab08

Browse files
chore: build pgvector from source
1 parent b513bd9 commit 3fbab08

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

Dockerfile

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
FROM pgvector/pgvector:pg16 AS builder
2-
31
FROM postgres:16-alpine
42

5-
COPY --from=builder /usr/lib/postgresql/16/lib/vector.so /usr/lib/postgresql/16/lib/vector.so
6-
COPY --from=builder /usr/share/postgresql/16/extension/vector* /usr/lib/postgresql/16/share/extension/
3+
RUN apk update && apk add --no-cache \
4+
build-base \
5+
git \
6+
postgresql-dev \
7+
clang20 \
8+
llvm20-dev \
9+
llvm20-libs \
10+
llvm20-linker-tools
11+
12+
RUN ln -s "$(which clang)" /usr/bin/clang-19 \
13+
&& ln -s "$(which clang++)" /usr/bin/clang++-19 \
14+
&& mkdir -p /usr/lib/llvm19/bin \
15+
&& ln -s /usr/bin/llvm-lto /usr/lib/llvm19/bin/llvm-lto
16+
17+
ENV CC=clang
18+
19+
RUN git clone --depth 1 https://github.com/pgvector/pgvector.git \
20+
&& cd pgvector \
21+
&& make \
22+
&& make install \
23+
&& cd .. \
24+
&& rm -rf pgvector
25+
26+
COPY docker-entrypoint-initdb.d/01-create-vector.sh /docker-entrypoint-initdb.d/
27+
RUN chmod +x /docker-entrypoint-initdb.d/01-create-vector.sh
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# create the extension in the default DB (usually $POSTGRES_DB or 'postgres')
5+
psql --username "$POSTGRES_USER" <<-EOSQL
6+
CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA public;
7+
EOSQL
8+
9+
# also install into template1 so any newly created database inherits it
10+
psql --username "$POSTGRES_USER" --dbname=template1 <<-EOSQL
11+
CREATE EXTENSION IF NOT EXISTS vector;
12+
EOSQL

0 commit comments

Comments
 (0)