From 11a22566ce83f7d29632dfdf072e147b0705372b Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 31 Jul 2021 13:23:52 +0200 Subject: [PATCH] Move from Docker Hub to GitHub Container Registry Depends on prebuild/docker-images#19. Effectively fixes a critical bug (prebuild/docker-images#17) for dockcross-based images. Those are: - `linux-armv6` - `linux-armv7` - `linux-arm64` - `android-armv7` - `android-arm64` Also pins image versions (to version 1) by default, which is now possible because the images are tagged with version numbers in addition to the `latest` tag. Image descriptions have moved to the prebuild/docker-images repository. --- README.md | 42 +++++++++++++----------------------------- index.js | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 3d3d626..9f1d810 100644 --- a/README.md +++ b/README.md @@ -26,39 +26,23 @@ To build for more than one platform, multiple `--image` arguments may be passed: prebuildify-cross -i linux-armv7 -i linux-arm64 -t .. ``` -Lastly, it's possible to use your own custom image with e.g. `-i my-namespace/my-image`. +By default [`prebuild/docker-images`](https://github.com/prebuild/docker-images) are used which are publicly hosted on the [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-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/` and if these don't contain a tag they're further expanded to `ghcr.io/prebuild/:` where `version` is currently 1. -## Images - -### `centos7-devtoolset7` - -Compile in CentOS 7, as a better alternative to (commonly) Ubuntu 16.04 on Travis. Makes the prebuild compatible with Debian 8, Ubuntu 14.04, RHEL 7, CentOS 7 and other Linux flavors with an old glibc. - -> The neat thing about this is that you get to compile with gcc 7 but glibc 2.17, so binaries are compatible for \[among others] Ubuntu 14.04 and Debian 8. -> -> The RHEL folks put in a ton of work to make the devtoolsets work on their older base systems (libc mainly), which involves shipping a delta library that contains the new stuff that can be statically linked in where it's used. We use this method for building Node binary releases. -> -> \-- [**@rvagg**](https://github.com/rvagg) ([prebuild/docker-images#8](https://github.com/prebuild/docker-images/pull/8)) - -By default the prebuild will be [tagged](https://github.com/prebuild/prebuildify#options) with the libc flavor to set it apart from Alpine prebuilds, e.g. `linux-x64/node.libc.node`. - -### `alpine` - -Compile in Alpine, which uses musl instead of glibc and therefore can't run regular linux prebuilds. Worse, it sometimes does successfully _load_ such a prebuild during `npm install` - which prevents a compilation fallback from kicking in - and then segfaults at runtime. You can fix this situation in two ways: by shipping an `alpine` prebuild and/or by shipping a `centos7-devtoolset7` prebuild, because the latter will be skipped in Alpine thanks to the `libc` tag. +To use `latest` images (not recommended) an image tag must be specified explicitly. For example: -By default the prebuild will be [tagged](https://github.com/prebuild/prebuildify#options) with the libc flavor, e.g. `linux-x64/node.musl.node`. - -### `linux-armv7` and `linux-arm64` - -Cross-compile for Linux ARM. These images thinly wrap [`dockcross`](https://github.com/dockcross/dockcross) images. - -By default the prebuild will be [tagged](https://github.com/prebuild/prebuildify#options) with the armv version (7 or 8, respectively). - -### `android-armv7` and `android-arm64` +``` +prebuildify-cross -i linux-armv7:latest -t .. +``` -Cross-compile for Android ARM. These images thinly wrap [`dockcross`](https://github.com/dockcross/dockcross) images. +## Images -By default the prebuild will be [tagged](https://github.com/prebuild/prebuildify#options) with the armv version (7 or 8, respectively). +- [`centos7-devtoolset7`](https://github.com/prebuild/docker-images#centos7-devtoolset7) +- [`alpine`](https://github.com/prebuild/docker-images#alpine) +- [`linux-armv6`](https://github.com/prebuild/docker-images#linux-armv6) +- [`linux-armv7`](https://github.com/prebuild/docker-images#linux-armv7) +- [`linux-arm64`](https://github.com/prebuild/docker-images#linux-arm64) +- [`android-armv7`](https://github.com/prebuild/docker-images#android-armv7) +- [`android-arm64`](https://github.com/prebuild/docker-images#android-arm64) ## References diff --git a/index.js b/index.js index 906c945..1ff3771 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,16 @@ module.exports = function (opts, callback) { function loop () { let image = images.shift() if (!image) return process.nextTick(callback) - if (!image.includes('/')) image = 'prebuild/' + image + + // Default to images from https://github.com/prebuild/docker-images + if (!image.includes('/')) { + image = 'ghcr.io/prebuild/' + image + + // Pin to version 1 by default + if (!image.includes(':')) { + image = image + ':1' + } + } dockerPull(image) .on('progress', progress) @@ -118,9 +127,9 @@ function prebuildifyArgv (argv, image) { } } - // TODO: move this to the docker images? - if (/^prebuild\/(linux|android)-arm/.test(image)) argv.push('--tag-armv') - if (/^prebuild\/(centos|alpine)/.test(image)) argv.push('--tag-libc') + // TODO: move this to the docker images (https://github.com/prebuild/docker-images/issues/11) + if (/^(ghcr\.io\/)?prebuild\/(linux|android)-arm/.test(image)) argv.push('--tag-armv') + if (/^(ghcr\.io\/)?prebuild\/(centos|alpine)/.test(image)) argv.push('--tag-libc') return argv }