Skip to content

Commit

Permalink
feat: dockerfile (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: usamoi <[email protected]>
  • Loading branch information
usamoi authored Aug 18, 2023
1 parent cfd893a commit 44490f5
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.idea/
/target
*.iml
**/*.rs.bk
Cargo.lock
.vscode
.ignore
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM postgres:15

ARG TAG=latest

COPY . /tmp/build
RUN (cd /tmp/build && ./docker.sh)
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 44490f5

Please sign in to comment.