diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..f2d472914 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.DS_Store +.idea/ +/target +*.iml +**/*.rs.bk +Cargo.lock +.vscode +.ignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..212420261 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM postgres:15 + +ARG TAG=latest + +COPY . /tmp/build +RUN (cd /tmp/build && ./docker.sh) diff --git a/README.md b/README.md index fbb37fe11..0b5363fa8 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,17 @@ cargo pgrx init --pg15=/usr/lib/postgresql/15/bin/pg_config cargo pgrx install --release ``` -You need restart your PostgreSQL server for the changes to take effect, like `systemctl restart postgresql.service`. +Configure your PostgreSQL by modifying the `shared_preload_libraries` to include `vectors.so`. + +```sh +psql -U postgres -c 'ALTER SYSTEM SET shared_preload_libraries = "vectors.so"' +``` + +You need restart the PostgreSQL cluster. + +```sh +sudo systemctl restart postgresql.service +``` @@ -61,8 +71,6 @@ You need restart your PostgreSQL server for the changes to take effect, like `sy Download the deb package in the release page, and type `sudo apt install vectors-pg15-*.deb` to install the deb package. - - Configure your PostgreSQL by modifying the `shared_preload_libraries` to include `vectors.so`. ```sh @@ -71,10 +79,37 @@ psql -U postgres -c 'ALTER SYSTEM SET shared_preload_libraries = "vectors.so"' You need restart the PostgreSQL cluster. -``` +```sh sudo systemctl restart postgresql.service ``` + + +
+ Install with docker + +By default, you will build the latest release. + +```sh +docker buildx build https://github.com/tensorchord/pgvecto.rs.git --tag vectors:latest +``` + +Or build with a specified tag. + +```sh +docker buildx build https://github.com/tensorchord/pgvecto.rs.git --tag vectors:tag --build-arg TAG=v0.0.0-nightly.20230818 +``` + +Now you can run the image. + +``` +docker run --name vectors-example -e POSTGRES_PASSWORD=a -e POSTGRES_DB=a -e POSTGRES_USER=a -p 9999:5432 -d vectors:latest +``` + +Reference: https://hub.docker.com/_/postgres/. + +
+ Connect to the database and enable the extension. ```sql diff --git a/docker.sh b/docker.sh new file mode 100755 index 000000000..a6a07db19 --- /dev/null +++ b/docker.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +set -e + +apt-get update +apt-get install -y wget +apt-get install -y curl + +if [ "$TAG" == "latest" ]; then + URL=https://api.github.com/repos/tensorchord/pgvecto.rs/releases/latest +else + URL=https://api.github.com/repos/tensorchord/pgvecto.rs/releases/tags/$TAG +fi + +DOWNLOAD=$(curl -s $URL | grep browser_download_url | grep -o 'https://[^ ]*vectors-pg15-[^ ]*amd64-unknown-linux-gnu\.deb') + +wget -O /tmp/vectors.deb $DOWNLOAD +apt-get install -y /tmp/vectors.deb +rm -f /tmp/vectors.deb + +echo "echo 'shared_preload_libraries = '\"'\"'vectors.so'\"'\"'' >> /var/lib/postgresql/data/postgresql.auto.conf" > /docker-entrypoint-initdb.d/vectors.sh