From b129dce6fd9b647e22a0bdc9f3b788dc520599c1 Mon Sep 17 00:00:00 2001 From: Keming Date: Fri, 27 Dec 2024 16:14:30 +0800 Subject: [PATCH] chore: fix the psql & release CI target, update readme (#158) - clean the target option - fix release CI - update readme about how to use the vectorchord-pgrx image --------- Signed-off-by: Keming --- .github/workflows/psql.yml | 4 ++-- README.md | 5 +++++ scripts/README.md | 28 ++++++++++++++++++++++++++-- tools/package.sh | 4 ++-- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/psql.yml b/.github/workflows/psql.yml index 0400ac5..8a7f798 100644 --- a/.github/workflows/psql.yml +++ b/.github/workflows/psql.yml @@ -73,8 +73,8 @@ jobs: VERSION: ${{ matrix.version }} PROFILE: "opt" run: | - docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE cargo build --lib --features pg${{ matrix.version }} --target $ARCH-unknown-linux-gnu --profile $PROFILE - docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE ./tools/schema.sh --features pg${{ matrix.version }} --target $ARCH-unknown-linux-gnu --profile $PROFILE + docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE cargo build --lib --features pg${{ matrix.version }} --profile $PROFILE + docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE ./tools/schema.sh --features pg${{ matrix.version }} --profile $PROFILE ./tools/package.sh docker build -t vchord:pg${{ matrix.version }} --build-arg PG_VERSION=${{ matrix.version }} -f ./docker/Dockerfile . diff --git a/README.md b/README.md index 3d53e54..9cd6cf2 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,12 @@ $$); To simplify the workflow, we provide end-to-end scripts for external index pre-computation, see [scripts](./scripts/README.md#run-external-index-precomputation-toolkit). +### Build the Postgres Docker Image with VectorChord extension + +Follow the steps in [Dev Guidance](./scripts/README.md#build-docker). + ### Installing From Source + Install pgrx according to [pgrx's instruction](https://github.com/pgcentralfoundation/pgrx?tab=readme-ov-file#getting-started). ```bash cargo install --locked cargo-pgrx diff --git a/scripts/README.md b/scripts/README.md index 1c282ea..938ae90 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,19 +1,43 @@ ## Build Docker +Users can choose to build the package with the provided docker image or create the development environment by themselves. + +- (option 1) With `vectorchord-pgrx` Image + +```shell +# use the required version of `pgrx` and `rust` +export PGRX_VERSION=$(awk -F'version = "=|"' '/^pgrx\s*=.*version/ {print $2}' Cargo.toml) +export RUST_TOOLCHAIN=$(awk -F'"' '/^\s*channel\s*=/ {print $2}' rust-toolchain.toml) +export PGRX_IMAGE=ghcr.io/tensorchord/vectorchord-pgrx:$PGRX_VERSION-$RUST_TOOLCHAIN + +docker run --rm -v .:/workspace $PGRX_IMAGE cargo build --lib --features pg16 --profile opt +docker run --rm -v .:/workspace $PGRX_IMAGE ./tools/schema.sh --features pg16 --profile opt +``` + +- (option 2) With Local Development Environment + ```shell sudo apt install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config clang cargo install --locked cargo-pgrx cargo pgrx init -cargo build --package vchord --lib --features pg16 --target x86_64-unknown-linux-gnu --profile opt -./tools/schema.sh --features pg16 --target x86_64-unknown-linux-gnu --profile opt +cargo build --package vchord --lib --features pg16 --profile opt +./tools/schema.sh --features pg16 --profile opt +``` + +- build the debian package +```shell export SEMVER="0.0.0" export VERSION="16" export ARCH="x86_64" export PLATFORM="amd64" export PROFILE="opt" ./tools/package.sh +``` + +- build the docker image +```shell docker build -t vchord:pg16-latest --build-arg PG_VERSION=16 -f ./docker/Dockerfile . ``` diff --git a/tools/package.sh b/tools/package.sh index 55f7036..3f6172e 100755 --- a/tools/package.sh +++ b/tools/package.sh @@ -13,9 +13,9 @@ rm -rf ./build/dir_deb rm -rf ./build/vchord-pg${VERSION}_${SEMVER}_${PLATFORM}.deb mkdir -p ./build/dir_zip -cp ./target/${ARCH}-unknown-linux-gnu/${PROFILE}/schema.sql ./build/dir_zip/vchord--$SEMVER.sql +cp ./target/${PROFILE}/schema.sql ./build/dir_zip/vchord--$SEMVER.sql sed -e "s/@CARGO_VERSION@/$SEMVER/g" < ./vchord.control > ./build/dir_zip/vchord.control -cp ./target/${ARCH}-unknown-linux-gnu/${PROFILE}/libvchord.so ./build/dir_zip/vchord.so +cp ./target/${PROFILE}/libvchord.so ./build/dir_zip/vchord.so zip ./build/vchord-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip -j ./build/dir_zip/* mkdir -p ./build/dir_deb