Last active
September 20, 2023 17:03
-
-
Save char0n/ba409dcc4a24bb4a68e88935065d4868 to your computer and use it in GitHub Desktop.
Installing specific Node.js version to in Ubuntu Docker Image using nvm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:jammy | |
# use bash as default shell | |
SHELL ["/bin/bash", "-c"] | |
# install prerequisites | |
RUN apt-get update -y && apt-get install -y wget | |
# install Node.js using nvm | |
RUN mkdir -p /usr/local/nvm | |
ENV NVM_DIR /usr/local/nvm | |
ENV NODE_VERSION 20.3.0 | |
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash | |
RUN source $NVM_DIR/nvm.sh \ | |
&& nvm install $NODE_VERSION \ | |
&& nvm alias default $NODE_VERSION \ | |
&& nvm use default | |
# add node and npm to path so the commands are available | |
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules | |
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment