diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s index 0b3a80f3..87094422 100644 --- a/16/Dockerfile.c10s +++ b/16/Dockerfile.c10s @@ -44,8 +44,9 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions RUN INSTALL_PKGS="rsync tar gettext-envsubst nss_wrapper-libs glibc-locale-source xz" && \ PSQL_PKGS="postgresql16-server postgresql16-contrib postgresql16-upgrade" && \ INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \ + PSQL_PKGS="$PSQL_PKGS postgresql16-pgvector" && \ yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS && \ - rpm -V $INSTALL_PKGS postgresql-server postgresql-contrib postgresql-upgrade && \ + rpm -V $INSTALL_PKGS postgresql-server postgresql-contrib postgresql-upgrade pgvector && \ postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \ yum -y clean all --enablerepo='*' && \ localedef -f UTF-8 -i en_US en_US.UTF-8 && \ diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s index 127f64a5..24d2c416 100644 --- a/16/Dockerfile.c9s +++ b/16/Dockerfile.c9s @@ -45,6 +45,7 @@ RUN { yum -y module enable postgresql:16 || :; } && \ INSTALL_PKGS="rsync tar gettext nss_wrapper-libs postgresql-server postgresql-contrib" && \ INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \ INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \ + INSTALL_PKGS="$INSTALL_PKGS pgvector" && \ yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \ diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora index 1edab58b..ef50aaa4 100644 --- a/16/Dockerfile.fedora +++ b/16/Dockerfile.fedora @@ -1,4 +1,4 @@ -FROM quay.io/fedora/s2i-core:40 +FROM quay.io/fedora/s2i-core:41 # PostgreSQL image for OpenShift. # Volumes: @@ -47,7 +47,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions RUN INSTALL_PKGS="rsync tar gettext postgresql-server postgresql-contrib nss_wrapper " && \ INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \ INSTALL_PKGS+=" findutils xz" && \ - INSTALL_PKGS+=" pgaudit" && \ + INSTALL_PKGS+=" pgaudit pgvector" && \ dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \ diff --git a/16/Dockerfile.rhel10 b/16/Dockerfile.rhel10 index 4c3fac4a..93b2724a 100644 --- a/16/Dockerfile.rhel10 +++ b/16/Dockerfile.rhel10 @@ -45,6 +45,7 @@ RUN INSTALL_PKGS="rsync tar gettext-envsubst nss_wrapper-libs glibc-locale-sourc PSQL_PKGS="postgresql16-server postgresql16-contrib" && \ INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \ INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \ + PSQL_PKGS="$PSQL_PKGS postgresql16-pgvector" && \ yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS && \ rpm -V $INSTALL_PKGS && \ postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \ diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9 index a3243da2..cd0373c5 100644 --- a/16/Dockerfile.rhel9 +++ b/16/Dockerfile.rhel9 @@ -46,6 +46,7 @@ RUN { yum -y module enable postgresql:16 || :; } && \ INSTALL_PKGS="rsync tar gettext bind9.18-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \ INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \ INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \ + INSTALL_PKGS="$INSTALL_PKGS pgvector" && \ yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \ diff --git a/examples/pgvector/README b/examples/pgvector/README new file mode 100644 index 00000000..0ac49b4b --- /dev/null +++ b/examples/pgvector/README @@ -0,0 +1,17 @@ +Open-source vector similarity search for Postgres + +Store your vectors with the rest of your data. Supports: + + exact and approximate nearest neighbor search + single-precision, half-precision, binary, and sparse vectors + L2 distance, inner product, cosine distance, L1 distance, Hamming distance, and Jaccard distance + any language with a Postgres client + + +Bind-mount this directory under /opt/app-root/src in the container, and all the +*.conf files from postgresql-cfg/ files will be included to postgresql.conf. + +This config file enables the pgvector extensions that is available in the container +image, but needs to be enabled. + +More about pgvector extension at https://github.com/pgvector/pgvector. diff --git a/examples/pgvector/postgresql-cfg/10_pgvector.conf b/examples/pgvector/postgresql-cfg/10_pgvector.conf new file mode 100644 index 00000000..e1ea1604 --- /dev/null +++ b/examples/pgvector/postgresql-cfg/10_pgvector.conf @@ -0,0 +1 @@ +shared_preload_libraries = 'vector' diff --git a/specs/multispec.yml b/specs/multispec.yml index d61fe7fb..f8c2ffa2 100644 --- a/specs/multispec.yml +++ b/specs/multispec.yml @@ -24,6 +24,17 @@ specs: img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" pkgs: "postgresql-server postgresql-contrib" + fedora41: + distros: + - fedora-41-x86_64 + s2i_base: quay.io/fedora/s2i-core + org: "fedora" + prod: "fedora" + openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}" + redhat_component: "postgresql-{{ spec.short }}-container" + img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" + pkgs: "postgresql-server postgresql-contrib" + rhel8: distros: - rhel-8-x86_64 @@ -85,7 +96,7 @@ specs: redhat_component: "postgresql-{{ spec.short }}-container" img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" pkgs: "postgresql{{ spec.short }}-server postgresql{{ spec.short }}-contrib postgresql{{ spec.short }}-upgrade" - check_pkgs: "postgresql-server postgresql-contrib postgresql-upgrade" + check_pkgs: "postgresql-server postgresql-contrib postgresql-upgrade pgvector" version: "12": @@ -149,6 +160,6 @@ matrix: - rhel-8-x86_64 - rhel-9-x86_64 - centos-stream-9-x86_64 - - fedora-40-x86_64 + - fedora-41-x86_64 - centos-stream-10-x86_64 - rhel-10-x86_64 diff --git a/src/Dockerfile b/src/Dockerfile index a14c383c..77e41b45 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -71,6 +71,14 @@ RUN {{ spec.environment_setup }} INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \ {% endif %} {% endif %} +{% if spec.version == "16" %} + {% if spec.prod in ["c9s", "rhel9"] %} + INSTALL_PKGS="$INSTALL_PKGS pgvector" && \ + {% endif %} + {% if spec.prod in ["c10s", "rhel10" ] %} + PSQL_PKGS="$PSQL_PKGS postgresql16-pgvector" && \ + {% endif %} +{% endif %} {% if spec.prod == "c10s" or spec.prod == "rhel10" %} yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS && \ rpm -V $INSTALL_PKGS {{ spec.check_pkgs }} && \ diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora index 8a1b9381..541c7b4d 100644 --- a/src/Dockerfile.fedora +++ b/src/Dockerfile.fedora @@ -1,7 +1,7 @@ -{% if spec.version == "16" or spec.version == "15" %} -FROM quay.io/fedora/s2i-core:40 +{% if spec.version == "16" %} +FROM quay.io/fedora/s2i-core:41 {% else %} -FROM quay.io/fedora/s2i-core:38 +FROM quay.io/fedora/s2i-core:40 {% endif %} # PostgreSQL image for OpenShift. @@ -56,7 +56,7 @@ RUN INSTALL_PKGS="rsync tar gettext postgresql{{ spec.short }}-server postgresql {% endif %} INSTALL_PKGS+=" findutils xz" && \ {% if spec.version == "16" %} - INSTALL_PKGS+=" pgaudit" && \ + INSTALL_PKGS+=" pgaudit pgvector" && \ {% else %} INSTALL_PKGS+=" postgresql{{ spec.short }}-pgaudit" && \ {% endif %} diff --git a/test/run_test b/test/run_test index edae43f2..bd05f237 100755 --- a/test/run_test +++ b/test/run_test @@ -27,6 +27,7 @@ run_s2i_enable_ssl_test run_upgrade_test run_migration_test run_pgaudit_test +run_pgvector_test run_env_extension_load_test run_logging_test " @@ -1039,6 +1040,60 @@ EOSQL" || ret=3 return $ret } +# run_pgvector_test +# -------------------- +# Configure container to include pgvector. Check +# that pgvector is loaded. +run_pgvector_test() +{ + local ret=0 + # extension pgvector is not available for older versions + case ${VERSION} in + 11|12|13|15) echo "pgvector not expected, test skipped."; return ;; + *) ;; + esac + case ${OS} in + rhel8) + echo "pgvector not expected, test skipped."; return ;; + *) ;; + esac + + local config_dir data_dir name=test-pgvector + + # create a dir for config + config_dir=$(mktemp -d --tmpdir vector-hook-volume.XXXXX) + add_cleanup_command /bin/rm -rf "$config_dir" + test -n "$DOCKER_EXTRA_ARGS" || cp -r "$test_dir"/examples/pgvector/* "$config_dir" + setfacl -R -m u:26:rwx "$config_dir" + + # create a dir for data + create_volume_dir + data_dir="${volume_dir}" + + DOCKER_ARGS=" +-e POSTGRESQL_ADMIN_PASSWORD=password +$DOCKER_EXTRA_ARGS +-v ${config_dir}:/opt/app-root/src:Z +-v ${data_dir}:/var/lib/pgsql/data:Z + " create_container "$name" + + assert_runtime_option "$name" shared_preload_libraries vector || ret=1 + wait_ready "$name" || \ + false "FAIL: Container did not start up properly." + + # enable the pgvector extension + docker exec -i $(get_cid "$name") bash -c "psql <