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

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

问题描述

我是AWS Elastic beantalk的用户,但有一个小问题。我想用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?

推荐答案

运行 apt-get安装节点 不安装Node.js ,因为这不是您要的软件包。

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

如果运行 apt-cache信息节点,您会看到正在安装的是业余分组无线节点程序(过渡包)

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安装说明

或者,如果您想从git进行构建,则可以这样做在Docker内部:

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

RUN 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

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

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