Docker Container中的Grunt构建返回非零代码:6

时间:2016-11-30 11:41:47

标签: node.js docker gruntjs dockerfile ubuntu-16.04

当我尝试构建一个docker容器时,我遇到了一个问题。我的docker文件就像

FROM ubuntu:16.04
# ... RUN apt-get update && install ...

EXPOSE 3005

WORKDIR /usr/src/app
RUN npm install forever -g && \
    npm install -g bower && \
    npm install -g grunt-cli
COPY . .
RUN npm install && bower install --allow-root
RUN grunt build

WORKDIR /usr/src/app/dist
CMD NODE_ENV=${APP_ENV} forever start --uid "my_app" --append server/app.js

它会产生The command '/bin/sh -c grunt build' returned a non-zero code: 6

我已经从here进行了检查,并推测它可能与~/.known_host有关,但我仍然在努力做同样的方法。你能帮忙解决一下吗?

为了您的信息,docker在injector步骤停止,并且定义如下

injector: {
      options: {

      },
      // Inject application script files into index.html (doesn't include bower)
      scripts: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/', '');
            filePath = filePath.replace('/.tmp/', '');
            return '<script src="' + filePath + '"></script>';
          },
          starttag: '<!-- injector:js -->',
          endtag: '<!-- endinjector -->'
        },
        files: {
          '<%= yeoman.client %>/index.html': [
              ['{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
               '!{.tmp,<%= yeoman.client %>}/app/app.js',
               '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.spec.js',
               '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js']
            ]
        }
      },

      // Inject component scss into app.scss
      sass: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/app/', '');
            filePath = filePath.replace('/client/components/', '');
            return '@import \'' + filePath + '\';';
          },
          starttag: '// injector',
          endtag: '// endinjector'
        },
        files: {
          '<%= yeoman.client %>/app/app.scss': [
            '<%= yeoman.client %>/{app,components}/**/*.{scss,sass}',
            '!<%= yeoman.client %>/app/app.{scss,sass}'
          ]
        }
      },

      // Inject component css into index.html
      css: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/', '');
            filePath = filePath.replace('/.tmp/', '');
            return '<link rel="stylesheet" href="' + filePath + '">';
          },
          starttag: '<!-- injector:css -->',
          endtag: '<!-- endinjector -->'
        },
        files: {
          '<%= yeoman.client %>/index.html': [
            '<%= yeoman.client %>/{app,components}/**/*.css'
          ]
        }
      }
    },

1 个答案:

答案 0 :(得分:0)

正如你在grunt中找到的那样,manual你有6个状态代码,因为你有警告。

可靠的解决方案是:

  1. 修正警告。
  2. grunt build =&gt; grunt build --force