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
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ ENV CERTS="{}" \
WAN_USERS='["all"]' \
HBA_EXTRA_RULES=""
RUN apk add --no-cache python3 py3-netifaces \
&& if [ "${PG_MAJOR:-0}" -ge 12 ]; then \
apk add --no-cache --virtual .pgvector-build build-base clang19 llvm19 linux-headers ca-certificates; \
&& if [ "${PG_MAJOR:-0}" -ge 13 ]; then \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the PG version bump go in a separate commit? Thanks for catching this, PGVector 8.x no longer supports pg 12

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @ 311d76e

PG_CLANG="$(pg_config --configure | tr "'" "\n" | sed -n 's/^CLANG=clang-//p')"; \
PG_LLVM="$(pg_config --configure | tr "'" "\n" | sed -n 's#^LLVM_CONFIG=/usr/lib/llvm\([0-9][0-9]*\)/bin/llvm-config#\1#p')"; \
Comment thread
ljmnoonan marked this conversation as resolved.
test -n "${PG_CLANG}" && test -n "${PG_LLVM}" && test "${PG_CLANG}" = "${PG_LLVM}"; \
apk add --no-cache --virtual .pgvector-build build-base linux-headers ca-certificates "clang${PG_CLANG}" "llvm${PG_LLVM}"; \
wget -qO- "https://github.com/pgvector/pgvector/archive/refs/tags/v${PGVECTOR_VERSION}.tar.gz" \
| tar -xz -C /tmp; \
cd "/tmp/pgvector-${PGVECTOR_VERSION}" \
Expand Down
67 changes: 67 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,73 @@ def test_hba_extra_rules_added(self):
for rule in hba_extra_rules:
self.assertIn(rule, hba_conf)

def test_pgvector_extension(self):
"""Test that pgvector is installed and works."""
if float(local.env["DOCKER_TAG"].split("-")[0]) < 13:
self.skipTest("pgvector not built for PostgreSQL < 13")
self.postgres_container = docker(
"container",
"run",
"-d",
"--network",
"lan",
"-e",
"POSTGRES_DB=test_db",
"-e",
"POSTGRES_PASSWORD=test_password",
"-e",
"POSTGRES_USER=test_user",
CONF_EXTRA,
self.image,
).strip()
self._check_local_connection()
self.assertEqual(
"vector\n",
docker(
"container",
"exec",
self.postgres_container,
"psql",
"--command",
"SELECT name FROM pg_available_extensions WHERE name = 'vector';",
"--dbname",
"test_db",
"--no-align",
"--tuples-only",
"--username",
"test_user",
),
)
docker(
"container",
"exec",
self.postgres_container,
"psql",
"--command",
"CREATE EXTENSION vector;",
"--dbname",
"test_db",
"--username",
"test_user",
)
self.assertEqual(
"1\n",
docker(
"container",
"exec",
self.postgres_container,
"psql",
"--command",
"SELECT ('[1,2,3]'::vector <-> '[1,2,4]'::vector)::int;",
"--dbname",
"test_db",
"--no-align",
"--tuples-only",
"--username",
"test_user",
),
)


if __name__ == "__main__":
unittest.main()
Loading