Skip to content

Commit

Permalink
Move from Docker Hub to GitHub Container Registry
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vweevers committed Jul 31, 2021
1 parent 492b09b commit 11a2256
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
42 changes: 13 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<image>` and if these don't contain a tag they're further expanded to `ghcr.io/prebuild/<image>:<version>` 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.
>
> \-- <cite>[**@rvagg**](https://github.com/rvagg) ([prebuild/docker-images#8](https://github.com/prebuild/docker-images/pull/8))</cite>
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

Expand Down
17 changes: 13 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 11a2256

Please sign in to comment.