diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d38ac5f..2d804b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ jobs: permissions: contents: read strategy: + fail-fast: false matrix: image: - alpine @@ -29,10 +30,16 @@ jobs: tags: | prebuild/${{ matrix.image }}:dev push: false - - name: Test + - name: Print versions run: | docker run --rm prebuild/${{ matrix.image }}:dev node -v docker run --rm prebuild/${{ matrix.image }}:dev npm -v + docker run --rm prebuild/${{ matrix.image }}:dev npx -v docker run --rm prebuild/${{ matrix.image }}:dev python --version docker run --rm prebuild/${{ matrix.image }}:dev npm ls node-gyp -g - docker run --rm prebuild/${{ matrix.image }}:dev env + - name: Print env + run: docker run --rm prebuild/${{ matrix.image }}:dev env + + # TODO: fix WORKDIR and permissions (#10) + # - name: Test node-gyp + # run: docker run --rm -v $(pwd)/test/native-addon:/home/node/app:z -w /home/node/app prebuild/${{ matrix.image }}:dev npm run install diff --git a/README.md b/README.md index c4b5613..4f36a45 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ ## About -All images include `node`, `npm`, `npx` and a preconfigured build toolchain suitable for `node-gyp` and `prebuildify`. For example: +All images include Node.js LTS, Python 3.x, npm and a preconfigured build toolchain suitable for `node-gyp` and `prebuildify`. For example: ``` -> docker run --rm -it ghcr.io/prebuild/alpine node -v +> docker run --rm ghcr.io/prebuild/alpine node -v v14.17.4 ``` @@ -25,8 +25,6 @@ FROM ghcr.io/prebuild/alpine:1 Within a major version range, we will not change toolchains, environment variables, working directories, users and more. However, the Node.js version will change without notice. We use Node.js [LTS](https://github.com/nodejs/Release) (at the time of building images) for a light maintenance effort. This is okay because `prebuildify` can target (the headers of) older Node.js versions while itself running on a newer version. -We've yet to align Python versions ([#15](https://github.com/prebuild/docker-images/issues/15)). A next major will use Python 3. - Images that are based on [`dockcross`](https://github.com/dockcross/dockcross) (see below) may inadvertently introduce breaking changes because `dockcross` does not use semantic versions ([dockcross/dockcross#399](https://github.com/dockcross/dockcross/issues/399)) and does not maintain a changelog that would allow us to easily categorize changes and then tag our images accordingly. If this concerns you we recommend pinning to an exact version (`x.x.x`) which we treat as immutable. ## Images diff --git a/alpine/Dockerfile b/alpine/Dockerfile index eaa706b..2f7e96a 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -2,11 +2,15 @@ FROM node:lts-alpine RUN addgroup -g 2000 travis && \ adduser -u 2000 -G travis -s /bin/sh -D travis && \ - apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python git + apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python3 git && \ + ln -sf python3 /usr/bin/python && \ + python --version USER node +ENV HOME /home/node # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false WORKDIR /app diff --git a/android-arm64/Dockerfile b/android-arm64/Dockerfile index 8d47e55..9dab02a 100644 --- a/android-arm64/Dockerfile +++ b/android-arm64/Dockerfile @@ -10,12 +10,13 @@ RUN groupadd --gid 1000 node && useradd --uid 1000 --gid node --shell /bin/bash curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ apt-get -y install nodejs && \ npm -v && \ - test -f ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip && \ + test -f ${CROSS_ROOT}/bin/llvm-strip && \ rm -rf /var/lib/apt/lists/* USER node +ENV HOME /home/node -ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip +ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/llvm-strip ENV PREBUILD_ARCH arm64 ENV PREBUILD_ARMV 8 ENV PREBUILD_PLATFORM android @@ -30,6 +31,7 @@ ENV GYP_DEFINES target_arch=arm64 android_target_arch=arm64 host_os=linux OS=and # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false # Set inherited dockcross labels to empty values. # Labels can't be deleted (https://github.com/moby/moby/issues/3465) diff --git a/android-armv7/Dockerfile b/android-armv7/Dockerfile index 9acdc07..60e3861 100644 --- a/android-armv7/Dockerfile +++ b/android-armv7/Dockerfile @@ -10,12 +10,13 @@ RUN groupadd --gid 1000 node && useradd --uid 1000 --gid node --shell /bin/bash curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ apt-get -y install nodejs && \ npm -v && \ - test -f ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip && \ + test -f ${CROSS_ROOT}/bin/llvm-strip && \ rm -rf /var/lib/apt/lists/* USER node +ENV HOME /home/node -ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip +ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/llvm-strip ENV PREBUILD_ARCH arm ENV PREBUILD_ARMV 7 ENV PREBUILD_PLATFORM android @@ -30,6 +31,7 @@ ENV GYP_DEFINES target_arch=arm android_target_arch=arm host_os=linux OS=android # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false # Set inherited dockcross labels to empty values. # Labels can't be deleted (https://github.com/moby/moby/issues/3465) diff --git a/centos7-devtoolset7/Dockerfile b/centos7-devtoolset7/Dockerfile index 1c9b1de..d9b65c1 100644 --- a/centos7-devtoolset7/Dockerfile +++ b/centos7-devtoolset7/Dockerfile @@ -5,12 +5,19 @@ USER 0 RUN groupadd -g 1000 node && useradd -g 1000 -u 1000 -m node && \ groupadd -g 2000 travis && useradd -g 2000 -u 2000 -m travis && \ curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash - && \ - yum install -y make nodejs && \ - npm -v + yum install -y make nodejs python3 && \ + sed -i 's/#!\/usr\/bin\/python/#!\/usr\/bin\/python2/' /usr/bin/yum && \ + ln -sf python3 /usr/bin/python && \ + yum clean all && \ + rm -rf /var/cache/yum && \ + npm -v && \ + python --version USER node +ENV HOME /home/node # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false WORKDIR /app diff --git a/linux-arm64/Dockerfile b/linux-arm64/Dockerfile index e0f539a..3e8e0d9 100644 --- a/linux-arm64/Dockerfile +++ b/linux-arm64/Dockerfile @@ -14,6 +14,7 @@ RUN groupadd --gid 1000 node && useradd --uid 1000 --gid node --shell /bin/bash rm -rf /var/lib/apt/lists/* USER node +ENV HOME /home/node ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip ENV PREBUILD_ARCH arm64 @@ -28,6 +29,7 @@ ENV TARGET_PLATFORM ${PREBUILD_PLATFORM} # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false # Set inherited dockcross labels to empty values. # Labels can't be deleted (https://github.com/moby/moby/issues/3465) diff --git a/linux-armv6/Dockerfile b/linux-armv6/Dockerfile index 82a726f..69fe736 100644 --- a/linux-armv6/Dockerfile +++ b/linux-armv6/Dockerfile @@ -14,6 +14,7 @@ RUN groupadd --gid 1000 node && useradd --uid 1000 --gid node --shell /bin/bash rm -rf /var/lib/apt/lists/* USER node +ENV HOME /home/node ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip ENV PREBUILD_ARCH arm @@ -28,6 +29,7 @@ ENV TARGET_PLATFORM ${PREBUILD_PLATFORM} # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false # Set inherited dockcross labels to empty values. # Labels can't be deleted (https://github.com/moby/moby/issues/3465) diff --git a/linux-armv7/Dockerfile b/linux-armv7/Dockerfile index 0988e47..0467cd8 100644 --- a/linux-armv7/Dockerfile +++ b/linux-armv7/Dockerfile @@ -14,6 +14,7 @@ RUN groupadd --gid 1000 node && useradd --uid 1000 --gid node --shell /bin/bash rm -rf /var/lib/apt/lists/* USER node +ENV HOME /home/node ENV PREBUILD_STRIP_BIN ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip ENV PREBUILD_ARCH arm @@ -28,6 +29,7 @@ ENV TARGET_PLATFORM ${PREBUILD_PLATFORM} # Disable npm update check ENV NO_UPDATE_NOTIFIER true +ENV npm_config_update_notifier false # Set inherited dockcross labels to empty values. # Labels can't be deleted (https://github.com/moby/moby/issues/3465) diff --git a/test/native-addon/.gitignore b/test/native-addon/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/test/native-addon/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/test/native-addon/.npmrc b/test/native-addon/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/test/native-addon/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/native-addon/binding.cc b/test/native-addon/binding.cc new file mode 100644 index 0000000..e255bdf --- /dev/null +++ b/test/native-addon/binding.cc @@ -0,0 +1,8 @@ +#define NAPI_VERSION 3 +#include + +napi_value init(napi_env env, napi_value exports) { + return exports; +} + +NAPI_MODULE(NODE_GYP_MODULE_NAME, init) diff --git a/test/native-addon/binding.gyp b/test/native-addon/binding.gyp new file mode 100644 index 0000000..69c1edd --- /dev/null +++ b/test/native-addon/binding.gyp @@ -0,0 +1,6 @@ +{ + "targets": [{ + "target_name": "native_addon", + "sources": ["binding.cc"] + }] +} diff --git a/test/native-addon/package.json b/test/native-addon/package.json new file mode 100644 index 0000000..1af1a4d --- /dev/null +++ b/test/native-addon/package.json @@ -0,0 +1,10 @@ +{ + "name": "native-addon", + "version": "0.0.0", + "description": "Test package", + "private": true, + "license": "MIT", + "scripts": { + "install": "node-gyp rebuild" + } +}