我的 Node.js 应用程序由两部分组成:一个 Express 后端和一个 React 前端。
我在这个结构中有两个 package.json 文件
package.json
/app/package.json
我想要做的是在我的前端文件夹应用程序中运行一个脚本来构建我的代码。
我想运行的脚本是npm install
and npm run build
部署完成后如何运行此脚本?
commands:
01_app_npm_install:
command: npm install
cwd: app/
02_app_npm_build:
command: npm run build
cwd: app/
但它返回一个错误,指出“没有这样的文件或目录:‘app/’。”
这可以在 aws 弹性豆茎上做到吗?
更新:
现在,这一点已经更加完善和明确。
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
原来的:
我自己没有使用Elastic Beanstalk 做过nodejs,但我做过很多Django。
The commands:
部分在项目文件就位之前运行。例如,您可以在此处安装服务器软件包。
The container_commands:
在文件被放入其最终目的地(对于nodejs来说似乎是/var/app/current)之前,部分在暂存目录中运行。如果需要,您可以在这里修改您的文件。
以上参考:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
您还可以运行部署后脚本。这没有很好的记录(至少没有)。你可以这样做:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
service httpd restart
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)