Compare commits

..

3 Commits

Author SHA1 Message Date
Will Jones
d85cb062d7 use manylinux containers locally 2023-05-24 22:58:41 -07:00
Will Jones
181f8e1ebf try manylinux again 2023-05-24 21:27:59 -07:00
Will Jones
c4237c61d5 fixes for action 2023-05-24 18:22:08 -07:00
4 changed files with 142 additions and 44 deletions

View File

@@ -120,30 +120,39 @@ jobs:
files: node/dist/vectordb-darwin*.tgz
node-linux:
name: Linux ${{ matrix.settings.arch}} native node module
runs-on: ubuntu-latest
needs: draft-release
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu:centos
- aarch64-unknown-linux-gnu:centos
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
libc:
- gnu
- musl
arch:
- x86_64
- aarch64
defaults:
run:
shell: bash
working-directory: node
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install system dependencies
- name: Build Linux GNU native node modules
if: ${{ matrix.libc == 'gnu' }}
run: |
sudo apt update
sudo apt install -y protobuf-compiler libssl-dev
cargo install cross
- name: Install npm dependencies
docker run \
-v $(pwd):/io -w /io \
quay.io/pypa/manylinux2014_${{ matrix.arch }} \
bash ci/build_linux_artifacts.sh ${{ matrix.arch }}-unknown-linux-gnu
- name: Build musl Linux native node modules
if: ${{ matrix.libc == 'musl' }}
run: |
cd node
npm ci
- name: Build Linux native node modules
run: bash ci/build_linux_artifacts.sh ${{ matrix.target }}
docker run \
-v $(pwd):/io -w /io \
quay.io/pypa/musllinux_1_1_${{ matrix.arch }} \
bash ci/build_linux_artifacts.sh ${{ matrix.arch }}-unknown-linux-musl
- uses: softprops/action-gh-release@v1
with:
draft: true

View File

@@ -1,14 +1,39 @@
# These make sure our builds are compatible with old glibc versions.
[target.x86_64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH protobuf-compiler",
# Install newer gfortran
"yum install -y openssl-devel unzip gcc-gfortran",
"scl enable devtoolset-11 bash",
# protobuf is too old, so we directly download binaries
"PB_REL=https://github.com/protocolbuffers/protobuf/releases",
"PB_VERSION=23.1",
"curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip",
"unzip protoc-$PB_VERSION-linux-x86_64.zip -d /usr/local",
]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main-centos"
[target.aarch64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH protobuf-compiler",
"yum install -y openssl-devel unzip",
# protobuf is too old, so we directly download binaries
"PB_REL=https://github.com/protocolbuffers/protobuf/releases",
"PB_VERSION=23.1",
"curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip",
"unzip protoc-$PB_VERSION-linux-x86_64.zip -d /usr/local",
]
# https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.aarch64-unknown-linux-gnu.centos
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main-centos"
[target.x86_64-unknown-linux-musl]
# https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.x86_64-unknown-linux-musl
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH",
]
[target.aarch64-unknown-linux-musl]
# https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.aarch64-unknown-linux-musl
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH",
]

View File

@@ -13,24 +13,69 @@
set -e
build_node_binaries() {
setup_dependencies() {
echo "Installing system dependencies..."
if [[ $1 == *musl ]]; then
# musllinux
apk add openssl-dev
else
# manylinux2014
yum install -y openssl-devel unzip
fi
if [[ $1 == x86_64* ]]; then
ARCH=x86_64
else
# gnu target
ARCH=aarch_64
fi
# Install new enough protobuf (yum-provided is old)
PB_REL=https://github.com/protocolbuffers/protobuf/releases
PB_VERSION=23.1
curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-$ARCH.zip
unzip protoc-$PB_VERSION-linux-$ARCH.zip -d /usr/local
}
install_node() {
echo "Installing node..."
if [[ $1 == *musl ]]; then
apk add nodejs-current npm
else
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
source "$HOME"/.nvm/nvm.sh
nvm install 17 # latest that supports glibc 2.17
fi
}
install_rust() {
echo "Installing rust..."
curl https://sh.rustup.rs -sSf | bash -s -- -y
export PATH="$PATH:/root/.cargo/bin"
rustup target add $1
}
build_node_binary() {
echo "Building node library for $1..."
pushd node
for target in $1
do
echo "Building node library for $target"
# cross doesn't yet pass this down to Docker, so we do it ourselves.
export CROSS_CONTAINER_OPTS="--platform linux/amd64"
npm run cross-release -- --target $target
npm run pack-build -- --target $target
done
if [[ $1 == *musl ]]; then
# This is needed for cargo to allow build cdylibs with musl
export RUSTFLAGS="-C target-feature=-crt-static"
fi
npm run build-release -- --target $1
npm run pack-build -- --target $1
popd
}
if [ -n "$1" ]; then
targets=$1
else
# targets="x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu aarch64-unknown-linux-musl x86_64-unknown-linux-musl"
targets="aarch64-unknown-linux-gnu"
fi
build_node_binaries $targets
TARGET=${1:-x86_64-unknown-linux-gnu}
# Others:
# aarch64-unknown-linux-gnu
# x86_64-unknown-linux-musl
# aarch64-unknown-linux-musl
setup_dependencies $TARGET
install_node
install_rust $TARGET
build_node_binary $TARGET

View File

@@ -68,18 +68,37 @@ bash ci/build_macos_artifacts.sh
### Build the Linux release libraries
One-time setup, building the Docker container
```shell
cat ci/ubuntu_build.dockerfile | docker build -t lancedb-node-build -
```
To build:
To build a Linux library, we need to use docker with a different build script:
```shell
ARCH=aarch64
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd):/io -w /io \
lancedb-node-build \
bash ci/build_linux_artifacts.sh
quay.io/pypa/manylinux2014_$ARCH \
bash ci/build_linux_artifacts.sh $ARCH-unknown-linux-gnu
```
You can change `ARCH` to `x86_64`.
Similar script for musl binaries:
```shell
ARCH=aarch64
docker run \
-v $(pwd):/io -w /io \
quay.io/pypa/musllinux_1_1_$ARCH \
bash ci/build_linux_artifacts.sh $ARCH-unknown-linux-musl
```
<!--
For debugging, use this snippet:
```shell
ARCH=aarch64
docker run -it \
-v $(pwd):/io -w /io \
quay.io/pypa/musllinux_1_1_$ARCH \
bash
```
-->