简体   繁体   中英

Deploying a multi-container docker application on elastic beanstalk: webpack command not found

I have a simple app consisting in a few containers behind an nginx reverse proxy. App is written in javascript and I used webpack for both front-end and back-end and additional modules. . Webpack is listed in devDependencies . I am trying to deploy this app on AWS elasticbeanstalk (at which I am totally new) in a Docker environment running on 64bit Amazon Linux 2/3.2.0 and I am facing this error:

...
somecontainer_1  | npm ERR! A complete log of this run can be found in:
somecontainer_1  | npm ERR!     /root/.npm/_logs/2020-10-19T21_35_51_966Z-debug.log
somecontainer_1  | 
somecontainer_1  | > fibworker@1.0.0 start /app
somecontainer_1  | > webpack --watch
somecontainer_1  | 
somecontainer_1  | sh: webpack: not found
somecontainer_1  | npm ERR! code ELIFECYCLE
somecontainer_1  | npm ERR! syscall spawn
somecontainer_1  | npm ERR! file sh
...

elasticbeanstalk runs npm install in production mode, so using some configuration I should be able to make elasticbeanstalk to install devDependencies and use webpack . I searched docs and read posts here and there. I tried to:

  • set the environment NPM_USE_PRODUCTION to false,
  • add the following ./ebextensions/something.config :
option_settings:
  - namespace: aws:elasticbeanstalk:environment
    option_name: NPM_USE_PRODUCTION
    value: false
  • use the ./ebextensions/something.config suggested here . I guess I that was the right way, but causes deploy to fail with this error:
    2020-10-19 21:26:40,329 [ERROR] Command npmglobals (sudo -u webapp npm i) failed
    2020-10-19 21:26:40,329 [ERROR] Error encountered during build of postbuild_0_fibsequence: Command npmglobals failed
    Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config 
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
    ToolError: Command npmglobals failed
    2020-10-19 21:26:40,331 [ERROR] -----------------------BUILD FAILED!------------------------
    2020-10-19 21:26:40,331 [ERROR] Unhandled exception during build: Command npmglobals failed
    Traceback (most recent call last):
      File "/opt/aws/bin/cfn-init", line 171, in <module>
        worklog.build(metadata, configSets)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
        Contractor(metadata).build(configSets, self)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
    self.run_config(config, worklog)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
      File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)

No luck. What am I missing?

Well what I miss is that AWS (at the time I was struggling against) does not care about dev dependencies of your node project, so my app does not fit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM