Skip to content

Commit

Permalink
Update the installation method for Node and add Node v20
Browse files Browse the repository at this point in the history
Refs DE-1662

Not removing Node 12 and 14, yet...

Change-Id: Ia14fc5368c4ffa9d0476624bbec83d0bbaf10594
Reviewed-on: https://gerrit.instructure.com/c/dockerfiles/+/326789
Reviewed-by: Jacob Burroughs <[email protected]>
QA-Review: James Belleau <[email protected]>
Tested-by: Service Cloud Jenkins <[email protected]>
  • Loading branch information
jpbelleau committed Sep 5, 2023
1 parent 9781ab5 commit 221a614
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 7 deletions.
9 changes: 8 additions & 1 deletion manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,26 @@ node:
base_image: core:bionic
'14': # Supported until 04/30/2023
node_version: '14'
npm_version: '9.8.1'
base_distro: focal
base_image: core:focal
multiarch: true
'16': # Supported until 04/30/2024
node_version: '16'
npm_version: '9.8.1'
base_distro: focal
base_image: core:focal
multiarch: true
'18':
'18': # Supported until 04/30/2025
node_version: '18'
base_distro: jammy
base_image: core:jammy
multiarch: true
'20': # Supported until 04/30/2026
node_version: '20'
base_distro: jammy
base_image: core:jammy
multiarch: true

node-passenger:
versions:
Expand Down
2 changes: 1 addition & 1 deletion node/14/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
COPY yarn-private /usr/local/bin

ENV NODE_VERSION 14
ENV NPM_VERSION latest
ENV NPM_VERSION 9.8.1

RUN mkdir -p /usr/src/app && chown docker:docker /usr/src/app
WORKDIR /usr/src/app
Expand Down
9 changes: 6 additions & 3 deletions node/16/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
COPY yarn-private /usr/local/bin

ENV NODE_VERSION 16
ENV NPM_VERSION latest
ENV NPM_VERSION 9.8.1

RUN mkdir -p /usr/src/app && chown docker:docker /usr/src/app
WORKDIR /usr/src/app

RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add - && \
echo "deb https://deb.nodesource.com/node_16.x focal main" > /etc/apt/sources.list.d/nodesource.list && \
RUN apt-get update && \
apt-get install -y curl && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && \
Expand Down
7 changes: 5 additions & 2 deletions node/18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ ENV NPM_VERSION latest
RUN mkdir -p /usr/src/app && chown docker:docker /usr/src/app
WORKDIR /usr/src/app

RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add - && \
echo "deb https://deb.nodesource.com/node_18.x jammy main" > /etc/apt/sources.list.d/nodesource.list && \
RUN apt-get update && \
apt-get install -y curl && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && \
Expand Down
45 changes: 45 additions & 0 deletions node/20/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# GENERATED FILE, DO NOT MODIFY!
# To update this file please edit the relevant template and run the generation
# task `rake generate:node`

ARG ROOT_PATH=instructure
FROM --platform=${TARGETPLATFORM} ${ROOT_PATH}/core:jammy
LABEL maintainer="Instructure"

USER root

ENV YARN_VERSION latest

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "" \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/

COPY yarn-private /usr/local/bin

ENV NODE_VERSION 20
ENV NPM_VERSION latest

RUN mkdir -p /usr/src/app && chown docker:docker /usr/src/app
WORKDIR /usr/src/app

RUN apt-get update && \
apt-get install -y curl && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/ && \
npm install -g "npm@$NPM_VERSION" && \
rm -rf /root/.npm/_cacache && \
npm cache clean --force

COPY npm-private /usr/local/bin


USER docker
16 changes: 16 additions & 0 deletions node/20/npm-private
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

npm config set "@${NPM_PRIVATE_SCOPE}:registry"="https:${NPM_PRIVATE_REGISTRY}"
npm config set "${NPM_PRIVATE_REGISTRY}:username"="${NPM_PRIVATE_USERNAME}"
npm config set "${NPM_PRIVATE_REGISTRY}:_password"="${NPM_PRIVATE_PASSWORD}"
npm config set "${NPM_PRIVATE_REGISTRY}:email"="${NPM_PRIVATE_EMAIL}"

npm "$@"
EXIT_CODE=$?

npm config delete "@${NPM_PRIVATE_SCOPE}:registry"
npm config delete "${NPM_PRIVATE_REGISTRY}:username"
npm config delete "${NPM_PRIVATE_REGISTRY}:_password"
npm config delete "${NPM_PRIVATE_REGISTRY}:email"

exit $EXIT_CODE
16 changes: 16 additions & 0 deletions node/20/yarn-private
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

npm config set "@${NPM_PRIVATE_SCOPE}:registry"="https:${NPM_PRIVATE_REGISTRY}"
npm config set "${NPM_PRIVATE_REGISTRY}:username"="${NPM_PRIVATE_USERNAME}"
npm config set "${NPM_PRIVATE_REGISTRY}:_password"="${NPM_PRIVATE_PASSWORD}"
npm config set "${NPM_PRIVATE_REGISTRY}:email"="${NPM_PRIVATE_EMAIL}"

yarn "$@"
EXIT_CODE=$?

npm config delete "@${NPM_PRIVATE_SCOPE}:registry"
npm config delete "${NPM_PRIVATE_REGISTRY}:username"
npm config delete "${NPM_PRIVATE_REGISTRY}:_password"
npm config delete "${NPM_PRIVATE_REGISTRY}:email"

exit $EXIT_CODE
16 changes: 16 additions & 0 deletions templates/node_install.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ENV NPM_VERSION <%= npm_version %>
RUN mkdir -p /usr/src/app && chown docker:docker /usr/src/app
WORKDIR /usr/src/app

<% if node_version.to_i < 16 -%>
<%# Non-active Node versions do not work with the new method (so far) -%>
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add - && \
echo "deb https://deb.nodesource.com/node_<%= node_version %>.x <%= base_distro %> main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
Expand All @@ -13,5 +15,19 @@ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dear
npm install -g "npm@$NPM_VERSION" && \
rm -rf /root/.npm/_cacache && \
npm cache clean --force
<% else -%>
RUN apt-get update && \
apt-get install -y curl && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_<%= node_version %>.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/ && \
npm install -g "npm@$NPM_VERSION" && \
rm -rf /root/.npm/_cacache && \
npm cache clean --force
<% end -%>

COPY npm-private /usr/local/bin

0 comments on commit 221a614

Please sign in to comment.