2017-02-02 73 views
0

Dockerfile的以下部分安装节点,但默认到v 4.2.6,如何安装最新的稳定版本7.4.0安装的NodeJS的最新稳定版本Dockerfile

RUN apt-get clean && apt-get update \ 
    && apt-get -yqq install \ 
    apache2 \ 
    nodejs \ ## nodejs installed here 
    php \ 
    php-mcrypt \ 
    php-curl \ 
    php-mbstring \ 
    php-xml \ 
    php-zip \ 
    libapache2-mod-php \ 
    php-mysql \ 
    git \ 
    supervisor \ 
    && apt-get -y autoremove \ 
    && apt-get clean \ 
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ 
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 
    && ln -sf /dev/stdout /var/log/apache2/access.log \ 
    && ln -sf /dev/stderr /var/log/apache2/error.log 

回答

0

据文档nodejs.org你可以这样安装:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs

所以,你可以Dockerfile是这样的:

RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash \ && apt-get clean && apt-get update \ && apt-get -yqq install \ apache2 \ nodejs \ ## It should be the good version

0
RUN apt-get clean && apt-get update \ 
    && apt-get -yqq install \ 
    apache2 \ 
    php \ 
    php-mcrypt \ 
    php-curl \ 
    php-mbstring \ 
    php-xml \ 
    php-zip \ 
    libapache2-mod-php \ 
    php-mysql \ 
    git \ 
    supervisor \ 
    && apt-get -y autoremove \ 
    && apt-get clean \ 
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ 
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 
    && ln -sf /dev/stdout /var/log/apache2/access.log \ 
    && ln -sf /dev/stderr /var/log/apache2/error.log \ 
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash && nvm install 7.4.0 \ 
    && nvm use 7.4.0 \