[英]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.我有一个简单的应用程序,包含几个位于nginx
反向代理后面的容器。 App is written in javascript and I used webpack
for both front-end and back-end and additional modules.应用程序是用 javascript 编写的,我将webpack
用于前端和后端以及附加模块。 . . Webpack
is listed in devDependencies
. Webpack
列在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:我正在尝试在运行于64bit Amazon Linux 2/3.2.0
上的Docker
环境中的 AWS elasticbeanstalk
(我是全新的)上部署此应用程序,我面临此错误:
...
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
. elasticbeanstalk
在生产模式下运行npm install
,因此使用一些配置我应该能够让elasticbeanstalk
安装devDependencies
并使用webpack
。 I searched docs and read posts here and there.我到处搜索文档并阅读帖子。 I tried to:我尝试过了:
NPM_USE_PRODUCTION
to false,将环境NPM_USE_PRODUCTION
设置为 false,./ebextensions/something.config
:添加以下./ebextensions/something.config
:option_settings:
- namespace: aws:elasticbeanstalk:environment
option_name: NPM_USE_PRODUCTION
value: false
./ebextensions/something.config
suggested here .使用此处建议的./ebextensions/something.config
。 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.好吧,我想念的是 AWS(当时我正在努力反对)不关心你的节点项目的开发依赖性,所以我的应用程序不适合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.