在 Dockerfile 中安装节点? [英] Install node in Dockerfile?

查看:18
本文介绍了在 Dockerfile 中安装节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 AWS elastic beanstalk 的用户,我有一个小问题.我想用 less+node 构建我的 CSS 文件.但是在使用 jenkins 构建时,我不知道如何在我的 dockerfile 中安装节点.

I am user of AWS elastic beanstalk, and I have a little problem. I want to build my CSS files with less+node. But I don`t know how to install node in my dockerfile, when building with jenkins.

这是我在 docker 中使用的安装包.我很乐意为您提供任何建议.

Here is installation packages what I am using in my docker. I will be glad for any suggestions.

FROM php:5.6-apache


# Install PHP5 and modules along with composer binary
RUN apt-get update
RUN apt-get -y install 
    curl 
    default-jdk 
    git 
    libcurl4-openssl-dev 
    libpq-dev 
    libmcrypt-dev 
    libpq5 
    npm 
    node 
    zlib1g-dev 
    libfreetype6-dev 
    libjpeg62-turbo-dev 
    libpng12-dev

RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

RUN docker-php-ext-install curl json mbstring opcache pdo_mysql zip gd exif sockets mcrypt

# Install pecl
RUN pecl install -o -f memcache-beta 
    && rm -rf /tmp/pear 
    && echo 'extension=memcache.so' > /usr/local/etc/php/conf.d/memcache.ini

在此之后,我使用代码运行我的 entrypoint.sh

After this I am runing my entrypoint.sh with code

#!/usr/bin/env sh

composer run-script post-install-cmd --no-interaction

chmod 0777 -R /var/app/app/cache
chmod 0777 -R /var/app/app/logs

exec apache2-foreground

但是后来我遇到了这个错误

But then I`ve got this error

 Error Output: [2016-04-04 11:23:44] assetic.ERROR: The template ":tmp:module.html.twig" contains an error: A template that extends another one cannot have a body in ":tmp:module.ht  
  ml.twig" at line 7.     

但是当我以这种方式安装在 Docker 容器节点中时

But when I install inside the Docker container node this way

apt-get install git-core curl build-essential openssl libssl-dev
 git clone https://github.com/nodejs/node.git
 cd node
 ./configure
 make
 sudo make install
 node -v

我可以构建我的 CSS.所以问题是..当我用 Jenkins 构建它时,上面的这个安装如何在我的 Dockerfile 中安装?

I can build my CSS. So question is..how this installation above make install inside my Dockerfile when I am building it with Jenkins?

推荐答案

Running apt-get install node 不安装Node.js,因为那不是你的包正在要求.

Running apt-get install node does not install Node.js, because that's not the package you're asking for.

如果你运行apt-cache info node,你可以看到你正在安装的是一个Amateur Packet Radio Node程序(过渡包)"

If you run apt-cache info node you can see that what you are installing is a "Amateur Packet Radio Node program (transitional package)"

您应该遵循 Node.js安装说明通过包管理器安装.

You should follow the Node.js install instructions to install via package manager.

或者,如果您喜欢从 git 构建,您可以在 Docker 中执行此操作:

Or if you like building from git, you can just do that inside Docker:

RUN apt-get install -y git-core curl build-essential openssl libssl-dev 
 && git clone https://github.com/nodejs/node.git 
 && cd node 
 && ./configure 
 && make 
 && sudo make install

这篇关于在 Dockerfile 中安装节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆