Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: bump Python from 2.x to 3.x (#15) #23

Merged
merged 5 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
permissions:
contents: read
strategy:
fail-fast: false
matrix:
image:
- alpine
Expand All @@ -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
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions android-arm64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions android-armv7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions centos7-devtoolset7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions linux-arm64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions linux-armv6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions linux-armv7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/native-addon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
1 change: 1 addition & 0 deletions test/native-addon/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
8 changes: 8 additions & 0 deletions test/native-addon/binding.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#define NAPI_VERSION 3
#include <node_api.h>

napi_value init(napi_env env, napi_value exports) {
return exports;
}

NAPI_MODULE(NODE_GYP_MODULE_NAME, init)
6 changes: 6 additions & 0 deletions test/native-addon/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"targets": [{
"target_name": "native_addon",
"sources": ["binding.cc"]
}]
}
10 changes: 10 additions & 0 deletions test/native-addon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "native-addon",
"version": "0.0.0",
"description": "Test package",
"private": true,
"license": "MIT",
"scripts": {
"install": "node-gyp rebuild"
}
}