prebuild-install icon indicating copy to clipboard operation
prebuild-install copied to clipboard

Mirroring with custom host much harder compared with node-pre-gyp

Open Fiouz opened this issue 3 years ago • 0 comments

Context

  • Hosting of binary on custom host
  • Package with working mirroring migrated from node-pre-gyp to prebuild-install
    • Migration did not change host
  • https://github.com/prebuild/prebuild-install/blob/8250adf958fcec6fb3ddfcd7dd5ceb0e0e29e419/util.js#L46-L60

Issue

Even though prebuild-install seems to have a similar option set compared to node-pre-gyp, mirroring is much harder to achieve and requires proper planning from the package maintainer.

Requirements for mirroring a binary that relies on node-pre-gyp:

  • (consumer) Mirror the <package.json>.binary.host
  • (consumer) Configure the npm <package>_binary_host_mirror variable to point to the mirror

Requirements for mirroring a binary that relies on prebuild-install with a custom host:

  • (package maintainer) Need to make sure that <package.json>.binary.remote_path ends with the hardcoded /{tag_prefix}{version}/ pattern. In case remote_path does not already include {tag_prefix}, prebuild-install must be invoked with --tag-prefix=
  • (consumer) Mirror the <package.json>.binary.host
  • (consumer) In case interoperability with node-pre-gyp is needed (e.g. case of realm library)
    • use the <package>_binary_host npm variable, and keep <package>_binary_host_mirror unchanged
    • configure <package>_binary_host npm variable to include whatever is needed so that the concatenation of <package>_binary_host + /{tag_prefix}{version}/ (taking into consideration that {tag_prefix} is controlled by package maintainer) matches the HTTP mirror

An example of such difficulty can be seen at https://github.com/realm/realm-js/issues/4667#issuecomment-1163201076

Is there a chance to simplify binary mirroring?

Fiouz avatar Jun 23 '22 23:06 Fiouz