1
0
mirror of https://github.com/tensorchord/pgvecto.rs.git synced 2025-04-18 21:44:00 +03:00

feat: dockerfile (#50)

Signed-off-by: usamoi <usamoi@outlook.com>
This commit is contained in:
Usamoi 2023-08-18 12:28:53 +08:00 committed by GitHub
parent cfd893a4e5
commit 44490f5cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 4 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
.DS_Store
.idea/
/target
*.iml
**/*.rs.bk
Cargo.lock
.vscode
.ignore

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM postgres:15
ARG TAG=latest
COPY . /tmp/build
RUN (cd /tmp/build && ./docker.sh)

View File

@ -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
```
</details>
@ -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.
</details>
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
```
</details>
<details>
<summary>Install with docker</summary>
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/.
</details>
Connect to the database and enable the extension.
```sql

21
docker.sh Executable file
View File

@ -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