Skip to content

Node.js 18.15.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@azasypkin azasypkin released this 14 Mar 15:15

Custom x64 and aarch64 Node.js 18.15.0 builds that are linked to glibc 2.17+.

The builds are generated with azasypkin/nodejs-custom:18.15.0 Docker image.

Build multi-platform build images (~10-15 minutes)

# Enable an execution of different multi-architecture containers by QEMU.
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

# Build multi-platform Docker image.
DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push \
  --platform linux/amd64,linux/arm64 \
  --build-arg UID=1000 --build-arg GID=1000 \
  --tag azasypkin/nodejs-custom:18.15.0 .

# Fetch the image locally.
docker pull --platform linux/amd64 azasypkin/nodejs-custom:18.15.0
docker pull --platform linux/arm64 azasypkin/nodejs-custom:18.15.0

Build Node.js (x64 - ~20 minutes, arm64 via QEMU - ~4 hours)

# Download and unpack Node.js source for the specific version.
curl --create-dirs --output-dir ./workdir/src -fsSLO --compressed \
  https://nodejs.org/download/release/v18.15.0/node-v18.15.0.tar.xz
tar -xf ./workdir/src/node-v18.15.0.tar.xz -C ./workdir/src

# Build x64 Node.js binary
docker run --rm -it --platform linux/amd64 \
  -v ./workdir:/home/node/workdir \
  azasypkin/nodejs-custom:18.15.0 \
  https://unofficial-builds.nodejs.org/download/release/ \
  v18.15.0
  
# Build aarch64 Node.js binary
docker run --rm -it --platform linux/arm64 \
  -v ./workdir:/home/node/workdir \
  azasypkin/nodejs-custom:18.15.0 \
  https://unofficial-builds.nodejs.org/download/release/ \
  v18.15.0

Resources

Dockerfile:

FROM centos:7

ARG GID=1000
ARG UID=1000

RUN groupadd --gid $GID node \
    && adduser --gid $GID --uid $UID node

RUN ulimit -n 1024 \
    && yum install -y epel-release \
    && yum install -y centos-release-scl-rh \
    && yum upgrade -y \
    && yum install -y \
         git \
         curl \
         make \
         python2 \
         python3 \
         ccache \
         xz-utils \
         devtoolset-9 \
         glibc-devel

COPY --chown=node:node run.sh /home/node/run.sh

USER node

VOLUME /home/node/workdir

ENTRYPOINT [ "/home/node/run.sh" ]

run.sh script:

#!/usr/bin/env bash

set -e
set -x

release_url_base="$1"
full_version="$2"
config_flags=${3:-""} #"--without-dtrace --without-npm --without-etw"

if [[ $(arch) == x86_64 ]]; then
  architecture="x64";
else
  architecture="arm64"
fi

cd "/home/node/workdir/src/node-${full_version}"

# Compile from source
export CCACHE_DIR="/home/node/workdir/.ccache-${architecture}"
export CC="ccache gcc"
export CXX="ccache g++"

. /opt/rh/devtoolset-9/enable

make -j"$(getconf _NPROCESSORS_ONLN)" binary V= \
  DESTCPU="$architecture" \
  ARCH="$architecture" \
  VARIATION="glibc-217" \
  DISTTYPE="release" \
  RELEASE_URLBASE="$release_url_base" \
  CONFIG_FLAGS="$config_flags"

mkdir -p /home/node/workdir/dist/
mv node-*.tar.?z /home/node/workdir/dist/