How to install nvm in docker?

后端 未结 14 935
陌清茗
陌清茗 2020-12-04 05:53

I am in the process of building a new Docker image and I\'m looking to get NVM installed so I can manage nodejs.

Reading the docs on how to install NVM they mention

14条回答
  •  醉梦人生
    2020-12-04 06:58

    Here is my working version

    FROM ubuntu:14.04
    
    # Declare constants
    ENV NVM_VERSION v0.29.0
    ENV NODE_VERSION v5.0.0
    
    # Replace shell with bash so we can source files
    RUN rm /bin/sh && ln -s /bin/bash /bin/sh
    
    # Install pre-reqs
    RUN apt-get update
    RUN apt-get -y install curl build-essential
    
    # Install NVM
    RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash
    
    # Install NODE
    RUN source ~/.nvm/nvm.sh; \
        nvm install $NODE_VERSION; \
        nvm use --delete-prefix $NODE_VERSION;
    

    Took help from @abdulljibali and @shamisis answers.

提交回复
热议问题