Skip to content
Open
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: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.
RUN tar -zcvf cdap-build-sources.tar.gz --exclude='.git*' --exclude='node_modules' --exclude='target' --exclude-vcs \
--exclude-vcs-ignores app-artifacts cdap eventwriters-extensions metricswriters-extensions security-extensions \
Dockerfile LICENSE.txt README.md && \
apt-get update && apt-get install -y lsb-release && \
DISTRO="$(lsb_release -s -c)" && \
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_10.x ${DISTRO} main" | tee -a /etc/apt/sources.list.d/nodesource.list && \
curl https://deb.nodesource.com/gpgkey/nodesource.gpg.key -o /usr/share/keyrings/nodesource.gpg.key && \
apt-key --keyring /usr/share/keyrings/nodesource.gpg add /usr/share/keyrings/nodesource.gpg.key && \
# installation of nodejs expects /bin/bash instead of /bin/sh
apt-get update && /bin/bash -c 'apt-get -y install nodejs' && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \
export NVM_DIR="$HOME/.nvm" && \
bash -c '. "$NVM_DIR/nvm.sh" && nvm install 22.22.3' && \
export PATH="$NVM_DIR/versions/node/v22.22.3/bin:$PATH" && \
Comment on lines +28 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There are two main issues with the current approach:

  1. Invalid Node.js Version: Node.js version 22.22.3 does not exist. Attempting to install this non-existent version will cause the build to fail.
  2. Unnecessary Complexity with NVM: Using nvm in a Dockerfile is generally discouraged because it is designed for interactive shells and managing multiple versions. For a Docker container, installing a single Node.js version directly is much cleaner, faster, and avoids the need to source environment files or manually update the PATH variable.

Recommendation:
Download and extract the official Node.js binary tarball directly to /usr/local.

    curl -fsSL https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.gz | tar -xzf - --strip-components=1 -C /usr/local && \

mvn install -f cdap -B -V -Ddocker.skip=true -DskipTests -P 'templates,!unit-tests' && \
mvn install -B -V -Ddocker.skip=true -DskipTests -P 'templates,dist,k8s,!unit-tests' \
-Dadditional.artifacts.dir="$DIR/app-artifacts" \
Expand Down
Loading