grunt-cli无法安装Docker音量,没有安装

时间:2015-06-30 15:26:10

标签: gruntjs docker

我使用以下Dockerfile设置了一个角度开发环境(不要尝试构建它,除非你真的很热情,需要一个年龄)。

FROM ubuntu:14.04

# build environment
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "nodejs", "npm", "git"]
RUN ["ln", "-s", "/usr/bin/nodejs", "/usr/bin/node"]
RUN ["npm", "install", "-g", "yo"]
RUN ["npm", "install", "-g", "bower"]
RUN ["npm", "install", "-g", "grunt-cli"]

WORKDIR /home/angular
ADD ./package.json /home/angular/package.json
ADD ./bower.json /home/angular/bower.json
ADD ./dist /home/angular/dist

RUN ["npm", "install"]
RUN ["bower", "install", "--allow-root"]

# sass depedencies
ENV RUBY_MAJOR 2.2
ENV RUBY_VERSION 2.2.2
ENV RUBY_DOWNLOAD_SHA256 5ffc0f317e429e6b29d4a98ac521c3ce65481bfd22a8cf845fa02a7b113d9b44

# some of ruby's build scripts are written in ruby
# we purge this later to make sure our final image uses what we just built
RUN ["apt-get", "install", "-y", "curl"]
RUN apt-get update \
    && apt-get install -y autoconf bison libgdbm-dev ruby \
    && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /usr/src/ruby \
    && curl -fSL -o ruby.tar.gz "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz" \
    && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \
    && tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \
    && rm ruby.tar.gz \
    && cd /usr/src/ruby \
    && autoconf \
    && ./configure --disable-install-doc \
    && make -j"$(nproc)" \
    && make install \
    && apt-get purge -y --auto-remove bison libgdbm-dev ruby \
    && rm -r /usr/src/ruby

# skip installing gem documentation
RUN echo 'gem: --no-rdoc --no-ri' >> "$HOME/.gemrc"

# install things globally, for great justice
ENV GEM_HOME /usr/local/bundle
ENV PATH $GEM_HOME/bin:$PATH

ENV BUNDLER_VERSION 1.10.5

RUN gem install bundler --version "$BUNDLER_VERSION" \
    && bundle config --global path "$GEM_HOME" \
    && bundle config --global bin "$GEM_HOME/bin"

# don't create ".bundle" in all our apps
ENV BUNDLE_APP_CONFIG $GEM_HOME

RUN gem install compass

VOLUME ["/home/me/code/correspondence/client/dist"]

ADD ./ /home/angular

如果我用以下方式运行:

sudo docker run -it me/angular /bin/bash

我可以毫无问题地使用grunt build。由于我没有将一个colume附加到dist,因此构建对其他容器(如Web服务器)没用。但是跑步:

sudo docker run -itv /home/me/code/correspondence/client/dist:/home/angular me/angular /bin/bash

导致grunt build命令不再可用于容器中:

grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started

唯一的区别是添加音量。如何添加音量会导致这种不同的行为?

1 个答案:

答案 0 :(得分:0)

我想这是因为您在图片中放置了一些文件/home/angular,当您将卷装入相同的路径(/home/angular)时,您的卷会隐藏原始文件。

引自documentation

  

注意:如果容器内已存在路径/opt/webapp   图像,其内容将被/src/webapp的内容替换   主机与mount

的预期行为保持一致

尝试将卷安装到另一个目录/home/angular/dist/client,例如。