gulp没有在Docker ubuntu上运行

时间:2016-07-30 00:05:56

标签: node.js docker npm gulp webpack

我正在尝试使用gulp在docker环境中启动webpack编译器。无论我尝试运行该命令(在ssh,Dockerfile或Procfile中),它都会失败并显示错误代码1并且不打印任何内容。

我检查了gulp并安装在node_packages中,但是当我从node_packages / .bin运行它时,我得到相同的响应。运行“npm”有效,但运行“node”似乎也不起作用。

有谁知道出了什么问题?

Dockerfile

FROM quay.io/aptible/ubuntu:14.04

# Basic dependencies
RUN apt-install build-essential python-dev python-setuptools
RUN apt-install libxml2-dev libxslt1-dev python-dev

# PostgreSQL dev headers and client (uncomment if you use PostgreSQL)
# RUN apt-install libpq-dev postgresql-client-9.3 postgresql-contrib-9.3

# MySQL dev headers (uncomment if you use MySQL)
RUN apt-install libmysqlclient-dev

RUN easy_install pip
RUN apt-install node
RUN apt-install npm

# Add requirements.txt and package.json ONLY, then run pip install, so that Docker cache won't
# bust when changes are made to other repo files
ADD requirements.txt /app/
ADD package.json /app/
WORKDIR /app
RUN pip install -r requirements.txt
RUN npm install

# Add repo contents to image
ADD . /app/
# RUN npm install -g gulp
# RUN gulp webpack:dev

#django environment variables
# ENV DATABASE_URL xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# ENV SECRET_KEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# ENV DJANGO_SETTINGS_MODULE xxxxxxxxxxxxx

ENV PORT 3000
EXPOSE 3000

procfile

web: sudo node_modules/.bin/gulp webpack:dev && sudo python app/manage.py runserver 0.0.0.0:$PORT

1 个答案:

答案 0 :(得分:1)

更改这些行

RUN apt-install build-essential python-dev python-setuptools
...
RUN apt-install node
RUN apt-install npm

到这些:

RUN apt-install build-essential curl python-dev python-setuptools
...
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN apt-get install -y nodejs

您注意我们为您的工具安装添加了curl,我们抓住节点ppa,然后安装它。这将为您提供该分支上更新的节点版本。它也将带有npm,你不需要单独安装它。

取消注释此行,因为您希望gulp成为全局安装

# RUN npm install -g gulp

相应地,在你的proc文件中 - 使用全局gulp