From 74ba4b9ddc8dbc70025843467ad9f1e1b5d36097 Mon Sep 17 00:00:00 2001
From: Louis <contact@louiscap.co>
Date: Thu, 28 Nov 2024 16:28:52 +0000
Subject: [PATCH] Include node for building frontend assets

---
 Dockerfile | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 8debba3..3433180 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,11 @@ ARG USERNAME=rustbuilder
 ARG USER_UID=1000
 ARG USER_GID=$USER_UID
 
-ARG RUST_VERSION=1.82
+ARG RUST_VERSION
+ARG NODE_VERSION
+
+ENV RUST_VERSION=${RUST_VERSION:-1.82}
+ENV NODE_VERSION=${NODE_VERSION:-22.11.0}
 
 RUN groupadd --gid $USER_GID $USERNAME \
     && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
@@ -18,9 +22,17 @@ RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
 
 USER $USERNAME
 
+ENV NVM_DIR=/home/${USERNAME}/.nvm
+
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
+
+RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
+RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
+RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
+
 RUN rustup install $RUST_VERSION && \
     rustup default $RUST_VERSION && \
     rustup install nightly && \
     cargo install cargo-binstall junitify cargo-nextest
 
-ENV PATH=$PATH:/home/$USERNAME/.cargo/bin
\ No newline at end of file
+ENV PATH="${PATH}:/home/${USERNAME}/.cargo/bin:${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/"
\ No newline at end of file
-- 
GitLab