From 109e09b94152c86e842f67663200261f459c94ff Mon Sep 17 00:00:00 2001 From: "Guillaume \"B.B.\" Van Hemmen" <GuillaumeHemmen@noreply.git.van-hemmen.com> Date: Mon, 14 Jul 2025 18:45:14 +0000 Subject: [PATCH] #2 - Fix: Ensure npx and node Availability (#3) This PR addresses the issue where `npx` and `node` were not available in the action pipelines. Additionally, it removes the reliance on `nvm` for installation. Instead, the latest available LTS version of Node.js is installed during the image build process, ensuring compatibility and seamless execution in the pipelines. This closes #2 Reviewed-on: https://git.van-hemmen.com/GuillaumeHemmen/debian-node-firebase/pulls/3 Co-authored-by: Guillaume "B.B." Van Hemmen <GuillaumeHemmen@noreply.git.van-hemmen.com> Co-committed-by: Guillaume "B.B." Van Hemmen <GuillaumeHemmen@noreply.git.van-hemmen.com> --- Dockerfile | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 945e4fe..977fa18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,23 +17,35 @@ RUN ln -snf /usr/share/zoneinfo/$ARG_TZ /etc/localtime && \ RUN apt-get update && \ apt-get upgrade -y && \ apt-get install -y \ - # Development tools build-essential \ - git \ - python3 \ - # System utilities ca-certificates \ curl \ + git \ gnupg2 \ + jq \ + nano \ procps \ + python3 \ sudo \ unzip \ - wget \ - nano \ - jq && \ + wget && \ # Clean up apt cache to reduce image size rm -rf /var/lib/apt/lists/* +# ------------------------------------------------------------------- +# Install Node.js from the official NodeSource repository (no NVM) +# ------------------------------------------------------------------- +RUN curl -fsSL "https://deb.nodesource.com/setup_${ARG_NODE_MAJOR}.x" | bash - && \ + apt-get update && apt-get install -y nodejs && \ + # Clean up apt cache to reduce image size + rm -rf /var/lib/apt/lists/* + + +# ------------------------------------------------------------------- +# Global npm tools +# ------------------------------------------------------------------- +RUN npm i -g yarn patch-package + # User setup and security configuration # Create non-root user 'coder' with sudo privileges RUN useradd -m -s /bin/bash -G sudo coder && \ @@ -53,22 +65,13 @@ RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/ # Switch to non-root user USER coder -# Configure bash environment -ENV BASH_ENV /home/coder/.bash_env -RUN touch "${BASH_ENV}" && \ - echo '. "${BASH_ENV}"' >> ~/.bashrc - # Set up global gitignore RUN curl -sL ${GITIGNORE_URL} -o /home/coder/.gitignore && \ git config --global core.excludesfile /home/coder/.gitignore -# Install Node.js using NVM -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | PROFILE="${BASH_ENV}" bash && \ - . $BASH_ENV && \ - nvm install ${ARG_NODE_MAJOR} && \ - nvm alias default ${ARG_NODE_MAJOR} && \ - nvm use ${ARG_NODE_MAJOR} && \ - npm i -g yarn patch-package - # Install Firebase CLI RUN curl -sL firebase.tools | bash + + +# optional: verify installation \ +RUN echo "node version $(node --version) | npm version $(npm --version)"