diff --git a/tools/nodejs/Dockerfile.template b/tools/nodejs/Dockerfile.template index 47e01c686fcb14bbc18522035da4ea68dc846393..e624a5d1702bc32b16e0529c1d580d1da58796f9 100644 --- a/tools/nodejs/Dockerfile.template +++ b/tools/nodejs/Dockerfile.template @@ -2,8 +2,7 @@ ARG ref=main -FROM --platform=amd64 ghcr.io/nicholasdille/docker-setup/base:${ref} AS prepare -WORKDIR /go/src/github.com/nodejs/node +FROM ghcr.io/nicholasdille/docker-setup/base:${ref} AS prepare ARG name ARG version RUN <<EOF @@ -20,50 +19,24 @@ else fi EOF RUN <<EOF -apt-get update -apt-get -y install --no-install-recommends \ - curl \ - python3 \ - gcc \ - g++ \ - linux-headers-generic \ - make -curl --silent --location --fail https://github.com/nodejs/node/archive/refs/tags/v${version}.tar.gz \ -| tar --extract --gzip --strip-components=1 -./configure \ - --prefix="${prefix}${target}" \ - --fully-static \ - --without-inspector \ - --enable-lto \ - --without-node-options \ - --without-dtrace \ - --without-npm \ - --with-intl=small-icu -make -j2 -make install -EOF - -FROM --platform=arm64 ghcr.io/nicholasdille/docker-setup/base:${ref} AS prepare -ARG name -ARG version -RUN <<EOF -MAJOR_VERSION="$( - curl --silent --location --fail https://github.com/nodejs/Release/raw/main/schedule.json \ - | jq -r 'to_entries[] | select(.value.maintenance > (now | todate)) | select(.value.lts != null) | select(.value.lts < (now | todate)) | .key' \ - | tr -d v -)" -if test "${version%%.*}" == "${MAJOR_VERSION}"; then - echo "### Version ${version} matches latest LTS ${MAJOR_VERSION}" -else - echo "### Version ${version} does not match latest LTS ${MAJOR_VERSION}" - exit 1 -fi -EOF -RUN <<EOF -curl --silent --verbose --location --fail "https://nodejs.org/dist/v${version}/node-v${version}-linux-${alt_arch}.tar.xz" \ +# https://nodejs.org/dist/v18.14.2/node-v18.14.2-linux-x64.tar.xz +# https://nodejs.org/dist/v18.14.2/node-v18.14.2-linux-arm64.tar.xz +case "${alt_arch}" in + amd64) + export arch_suffix=x64 + ;; + arm64) + export arch_suffix=arm64 + ;; + *) + echo "ERROR: Unknown architecture (${alt_arch})." + exit 1 + ;; +esac +curl --silent --location --fail "https://nodejs.org/dist/v${version}/node-v${version}-linux-${arch_suffix}.tar.xz" \ | tar --extract --xz --directory="${prefix}${target}" --strip-components=1 --no-same-owner \ - "node-v${version}-linux-${alt_arch}/bin" \ - "node-v${version}-linux-${alt_arch}/include" \ - "node-v${version}-linux-${alt_arch}/lib" \ - "node-v${version}-linux-${alt_arch}/share" + "node-v${version}-linux-${arch_suffix}/bin" \ + "node-v${version}-linux-${arch_suffix}/include" \ + "node-v${version}-linux-${arch_suffix}/lib" \ + "node-v${version}-linux-${arch_suffix}/share" EOF \ No newline at end of file diff --git a/tools/npm/Dockerfile.template b/tools/npm/Dockerfile.template index 7a2418a1513aa647c4af00eafc05d7e763236414..a2472ae03a5f27e78769c3f4d13c804b3afa8d01 100644 --- a/tools/npm/Dockerfile.template +++ b/tools/npm/Dockerfile.template @@ -2,25 +2,5 @@ ARG ref=main -FROM ghcr.io/nicholasdille/docker-setup/nodejs:${ref} AS nodejs - -FROM --platform=amd64 ghcr.io/nicholasdille/docker-setup/base:${ref} AS prepare -COPY --link --from=nodejs / / -WORKDIR /tmp/node -ARG name -ARG version -RUN <<EOF -curl --silent --location --fail "https://registry.npmjs.org/npm/${version}" \ -| jq --raw-output '.dist.tarball' \ -| xargs curl --silent --location --fail \ -| tar --extract --gzip --strip-components=1 --no-same-owner -node bin/npm-cli.js install --global --prefix "${prefix}${target}" --force /tmp/node -EOF -COPY <<EOF ${prefix}${target}/etc/npmrc -globalconfig=/etc/npmrc -globalignorefile=/etc/npmignore -prefix=/usr/local -EOF - -FROM --platform=amd64 ghcr.io/nicholasdille/docker-setup/base:${ref} AS prepare +FROM ghcr.io/nicholasdille/docker-setup/base:${ref} AS prepare COPY <<EOF ${prefix}${target}/var/cache/docker-setup/npm-is-included-in-prebuilt-binaries-of-nodejs \ No newline at end of file