tensorchord / pgvecto.rs

Scalable, Low-latency and Hybrid-enabled Vector Search in Postgres. Revolutionize Vector Search, not Database.
https://docs.pgvecto.rs/getting-started/overview.html
Apache License 2.0
1.75k stars 71 forks source link

Getting vector.so not found in cloudnative pg cluster #612

Open gregkonush opened 1 week ago

gregkonush commented 1 week ago

version 0.3

{"level":"info","ts":"2024-11-08T08:47:59.738349871Z","logger":"pg_ctl","msg":"waiting for server to start....2024-11-08 08:47:59.738 UTC [30] FATAL: could not access file \"vectors.so\": No such file or directory","pipe":"stdout","logging_pod":"ecran-vector-cluster-1-initdb"}

kubernetes manifest

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: ecran-vector-cluster
  namespace: ecran
spec:
  instances: 3
  bootstrap:
    initdb:
      database: ecran
      postInitApplicationSQL:
        - ALTER SYSTEM SET search_path TO "$user", public, vectors;
        - CREATE EXTENSION IF NOT EXISTS "vectors";
        - ALTER SYSTEM SET shared_preload_libraries = 'vectors';
      owner: ecran
      secret:
        name: ecran-cluster-secret
      dataChecksums: true
      encoding: "UTF8"
  storage:
    size: 5Gi
  imageName: kalmyk.duckdns.org/lab/vecteur:16.4
  imagePullSecrets:
    - name: kalmyk-registry
  postgresql:
    shared_preload_libraries:
      - "vectors.so"

Dockerfile

# syntax=docker/dockerfile-upstream:master
FROM ghcr.io/cloudnative-pg/postgresql:16

ARG CNPG_TAG
ARG PGVECTORS_TAG
ARG TARGETARCH

# drop to root to install packages
USER root

# install pgvecto.rs
ADD https://github.com/tensorchord/pgvecto.rs/releases/download/$PGVECTORS_TAG/vectors-pg${CNPG_TAG%.*}_${PGVECTORS_TAG#"v"}_$TARGETARCH.deb ./pgvectors.deb
RUN apt install ./pgvectors.deb

USER postgres

bash script to build image

#!/bin/bash

# Set variables
IMAGE_NAME="kalmyk.duckdns.org/lab/vecteur"
DOCKERFILE="services/vecteur/Dockerfile"
CONTEXT_PATH="services/vecteur"

TARGETARCH="arm64"
CNPG_TAG="16"

# Check if a tag is provided as an argument
if [ $# -eq 1 ]; then
    TAG=$1
else
    # If no tag is provided, use the current date and time
    TAG=$(date +"%Y%m%d_%H%M%S")
fi

# Full image name with tag
FULL_IMAGE_NAME="${IMAGE_NAME}:${TAG}"

# Build the Docker image
echo "Building Docker image: ${FULL_IMAGE_NAME}"
docker buildx build \
    --platform linux/${TARGETARCH} \
    --build-arg PGVECTORS_TAG=v0.3.0 \
    --build-arg TARGETARCH=${TARGETARCH} \
    --build-arg CNPG_TAG=${CNPG_TAG} \
    -t ${FULL_IMAGE_NAME} \
    -f ${DOCKERFILE} ${CONTEXT_PATH} \
    --push

# Check if the build was successful
if [ $? -eq 0 ]; then
    echo "Docker image built and pushed successfully: ${FULL_IMAGE_NAME}"
else
    echo "Docker image build or push failed"
    exit 1
fi