Skip to content

Commit

Permalink
Added prebuilt Linux ARM64 binaries to CI
Browse files Browse the repository at this point in the history
refs #1362

- the referenced PR added Linux ARM64 and ARMv7 prebuilds to CI so we can
  get prebuilt binaries upon releasing
- CI has recently been reworked so I've rebased the PR and fixed it up
- unfortunately, `node-pre-gyp` seems to ignore the difference between
  armv6 and armv7, and treats them both as `arm` so I've had to disable
  prebuilds for them for now
- building via QEMU is INCREDIBLY slow so I've configured
  it to only run during a release or upon manual execution
- full credit to @n1ru4l for the original PR
  • Loading branch information
daniellockyer committed Apr 14, 2022
1 parent 290d34f commit 122d2b8
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,53 @@ jobs:
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}
build-qemu:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
node:
- 16
architecture:
- linux/arm64
variant:
- bullseye
- alpine
name: ${{ matrix.variant }} ${{ matrix.architecture }} - Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build binaries and test
run: |
docker buildx build \
--file ./tools/BinaryBuilder.Dockerfile \
--load \
--tag sqlite-builder \
--platform ${{ matrix.architecture }} \
--no-cache \
--build-arg VARIANT=${{ matrix.variant }} \
--build-arg NODE_VERSION=${{ matrix.node }} \
.
CONTAINER_ID=$(docker create -it sqlite-builder)
docker cp $CONTAINER_ID:/usr/src/build/build/ ./build
- name: Upload binaries to commit artifacts
uses: actions/upload-artifact@v3
if: matrix.node == 16
with:
name: prebuilt-binaries
path: build/stage/*/*
retention-days: 7

- name: Upload binaries to GitHub Release
run: yarn node-pre-gyp-github publish
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,27 @@ The module uses [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) to downlo
Format: `napi-v{napi_build_version}-{platform}-{libc}-{arch}`

* `napi-v3-darwin-unknown-x64`
* `napi-v3-linux-glibc-arm64`
* `napi-v3-linux-glibc-x64`
* `napi-v3-linux-musl-arm64`
* `napi-v3-win32-unknown-ia32`
* `napi-v3-win32-unknown-x64`
* `napi-v6-darwin-unknown-x64`
* `napi-v6-linux-glibc-arm64`
* `napi-v6-linux-glibc-x64`
* `napi-v6-linux-musl-arm64`
* `napi-v6-win32-unknown-ia32`
* `napi-v6-win32-unknown-x64`

Unfortunately, [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).

Support for other platforms and architectures may be added in the future if CI supports building on them.

If your environment isn't supported, it'll use `node-gyp` to build SQLite but you will need to install a C++ compiler and linker.

### Other ways to install

It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#building-from-the-source)).
It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#source-install)).

The `sqlite3` module also works with [node-webkit](https://github.com/rogerwang/node-webkit) if node-webkit contains a supported version of Node.js engine. [(See below.)](#building-for-node-webkit)

Expand Down
25 changes: 25 additions & 0 deletions tools/BinaryBuilder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG NODE_VERSION=16
ARG VARIANT=bullseye

FROM node:$NODE_VERSION-$VARIANT

ARG VARIANT

RUN if [ "$VARIANT" = "alpine" ] ; then apk add build-base python3 --update-cache ; fi

WORKDIR /usr/src/build

COPY . .
RUN npm install --ignore-scripts

# Workaround for https://github.com/mapbox/node-pre-gyp/issues/644
RUN cd node_modules/\@mapbox/node-pre-gyp \
&& npm install [email protected] \
&& sed -i -e s/\'fs/\'fs-extra/ -e s/fs\.renameSync/fs.moveSync/ ./lib/util/napi.js

RUN npx node-pre-gyp configure
RUN npx node-pre-gyp build
RUN npm run test
RUN npx node-pre-gyp package

CMD ["sh"]

0 comments on commit 122d2b8

Please sign in to comment.