Code Monkey home page Code Monkey logo

prebuildify-cross's Introduction

prebuildify-cross

Compile prebuilds in Docker, supporting Linux (including Debian 8, Ubuntu 14.04, RHEL 7, CentOS 7 and up), Alpine Linux, ARM Linux devices like the Raspberry Pi and mobile ARM devices like Android.

Runs prebuildify in preconfigured prebuild/docker-images containers to compile and name prebuilds for a certain platform. This means you don't have to worry about GCC flags, environment variables or system dependencies. In addition, prebuildify-cross copies only npm package files to Docker (following the rules of .npmignore and files) and mounts node_modules removing the need for a repeated npm install.

Install

Depends on having Docker installed, as well as prebuildify and node-gyp:

npm install --save-dev prebuildify node-gyp prebuildify-cross

Usage

The prebuildify-cross cli forwards all command line arguments to prebuildify, but adds an --image or -i argument. For example, the following command will invoke prebuildify -t 8.14.0 --napi --strip in a CentOS container and copy the resulting prebuild to ./prebuilds:

prebuildify-cross -i centos7-devtoolset7 -t 8.14.0 --napi --strip

To build for more than one platform, multiple --image arguments may be passed:

prebuildify-cross -i linux-armv7 -i linux-arm64 -t ..

By default prebuild/docker-images are used which are publicly hosted on the GitHub Container Registry (ghcr.io). It's possible to use custom images with e.g. -i my-namespace/my-image. Image arguments that don't contain a forward slash are expanded to ghcr.io/prebuild/<image> and if these don't contain a tag they're further expanded to ghcr.io/prebuild/<image>:<version> where version is currently 2.

To use latest images (not recommended) an image tag must be specified explicitly. For example:

prebuildify-cross -i linux-armv7:latest -t ..

When working in a monorepo, where ./node_modules does not contain the dependencies that prebuildify-cross relies upon, a custom path can be provided with --modules. It can be an absolute path or relative to the current working directory. For example:

prebuildify-cross --modules ../../node_modules -i linux-armv7:latest -t 20.0.0 --strip

Images

References

License

GPL-3.0

prebuildify-cross's People

Contributors

ahdinosaur avatar kirrg001 avatar ralphtheninja avatar thegecko avatar vweevers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

prebuildify-cross's Issues

Dependencies

In order to fully build rocksdb I would like to request the following deps be available in the docker image:

  • folly
  • boost
  • zstd
  • jemalloc
  • tbb

V4 not released on npm

You can check this here

For the moment I use the github notation inside my package.json:

    "prebuildify-cross": "github:prebuild/prebuildify-cross#v4.0.0"

npm ERR! canceled

Hi there!

I am running into an error. I have tried different images and different node versions.

$ npx prebuildify-cross -i linux-arm64 -t [email protected] --strip
prebuildify-cross run ghcr.io/prebuild/linux-arm64:2
prebuildify -t [email protected] --strip --tag-armv

npm ERR! canceled
npm ERR! A complete log of this run can be found in:
npm ERR! /home/node/.npm/_logs/2024-01-04T21_17_05_957Z-debug-0.log

First of all, it was really hard to get the npm log file out of the docker container.
I had to add remove: false to the dockerRun command.

This is the npm log from the container:

0 verbose cli /usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 5ms
6 timing config:load:builtin Completed in 6ms
7 timing config:load:cli Completed in 4ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/home/node/app/.npmrc Completed in 0ms
10 timing config:load:project Completed in 23ms
11 timing config:load:file:/home/node/.npmrc Completed in 0ms
12 timing config:load:user Completed in 2ms
13 timing config:load:file:/usr/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 2ms
17 timing config:load:setEnvs Completed in 3ms
18 timing config:load Completed in 47ms
19 timing npm:load:configload Completed in 48ms
20 timing npm:load:mkdirpcache Completed in 5ms
21 timing npm:load:mkdirplogs Completed in 2ms
22 verbose title npm exec prebuildify -t [email protected] --strip --tag-armv
23 verbose argv "exec" "--yes" "false" "--" "prebuildify" "-t" "[email protected]" "--strip" "--tag-armv"
24 timing npm:load:setTitle Completed in 4ms
25 timing config:load:flatten Completed in 10ms
26 timing npm:load:display Completed in 14ms
27 verbose logfile logs-max:10 dir:/home/node/.npm/_logs
28 verbose logfile /home/node/.npm/_logs/2024-01-04T21_17_05_957Z-debug-0.log
29 timing npm:load:logFile Completed in 16ms
30 timing npm:load:timers Completed in 1ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 92ms
33 silly logfile done cleaning log files
34 timing arborist:ctor Completed in 3ms
35 http fetch GET 200 https://registry.npmjs.org/prebuildify 277ms (cache miss)
36 timing arborist:ctor Completed in 0ms
37 timing arborist:ctor Completed in 0ms
38 timing command:exec Completed in 723ms
39 verbose stack Error: canceled
39 verbose stack     at exec (/usr/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:230:17)
39 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:78:5)
40 verbose cwd /home/node/app
41 verbose Linux 6.1.57-0-virt
42 verbose node v18.12.1
43 verbose npm  v8.19.2
44 error canceled
45 verbose exit 1
46 timing npm Completed in 967ms
47 verbose code 1
48 error A complete log of this run can be found in:
48 error     /home/node/.npm/_logs/2024-01-04T21_17_05_957Z-debug-0.lo

The log file is not really helpful. I don't know why it's failing. It looks to me that the prebuildify command in the container is failing but I don't know why. Any help would be appreciated :)

I am able to generate prebuilds with latest version of prebuildify on my macbook without any issues.

$ node -v
v18.14.2

$ npx prebuildify-cross
5.0.0

Darwin x64

Thank you!

Update README

Once #4 has been merged we should

  • remove the first script example since prebuildify-cross now invokes prebuildify directly (not via npm run prebuild)
  • document arguments passing to prebuildify via --

use own Docker images

at the moment, given the compilation target we're using the respective Docker image from dockcross, then adding Node.js on top. this means building for every compilation target means downloading each image and then adding Node.js on top. it would be more efficient if we had a common base image with Node.js already installed and had our own set of compilation target images using our base image.

Installing further development packages

This is a great project.

I was wondering what the recommended approach would be for adding a common package to all of the images for a specific setup.

e.g. in my situation, I need prebuildify docker images which include libudev-dev.

I can see two approaches, both with drawbacks:

  • Derive our own docker images adding this package. This approach requires maintenance of each derived image (current count is 7). I've also found this works in some cases, but I've had issues with the arm based images and the package still isn't found when using:
FROM gchr.io/prebuild/linux-armv6:1
USER 0
RUN apt-get -y update && apt-get -y install libudev-dev
USER node
  • Use a prebuildify preinstall command to install the package. This doesn't feel right architecturally, but is easier to maintain without derived docker images. This approach also fails because sudo isn't allowed.

Latest version depends on vulnerable packages

Output of npm audit

# npm audit report

debug  <2.6.9
Regular Expression Denial of Service in debug - https://github.com/advisories/GHSA-gxpj-cx7g-858c
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/docker-run/node_modules/debug
  docker-run  *
  Depends on vulnerable versions of debug
  node_modules/docker-run
    prebuildify-cross  >=4.0.0
    Depends on vulnerable versions of docker-run
    node_modules/prebuildify-cross

trim-newlines  <3.0.1
Severity: high
Regular Expression Denial of Service in trim-newlines - https://github.com/advisories/GHSA-7p7h-4mm5-852v
fix available via `npm audit fix`
node_modules/trim-newlines
  meow  3.4.0 - 5.0.0
  Depends on vulnerable versions of trim-newlines
  node_modules/meow

5 vulnerabilities (3 low, 2 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.