语境
我正在使用 Elastic Beanstalk 部署一个非常简单的测试应用程序。我有几个要使用 apt 安装的软件包。我01_installations.sh
在目录中包含了一个安装脚本.platform/hooks/prebuild
。当我压缩我的应用程序并部署到 Elastic Beanstalk 时,日志确认预构建脚本运行,但它没有权限。
2020/08/12 21:03:46.674234 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/12 21:03:46.674256 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2020/08/12 21:03:46.674296 [INFO] Following platform hooks will be executed in order: [01_installations.sh]
2020/08/12 21:03:46.674302 [INFO] Running platform hook: .platform/hooks/prebuild/01_installations.sh
2020/08/12 21:03:46.674482 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/01_installations.sh failed with error fork/exec .platform/hooks/prebuild/01_installations.sh: permission denied
问题
我的理解是权限被拒绝,因为我没有添加chmod +x
使 .sh 文件可执行。正如有关平台挂钩的 AWS 文档所述:“使用 chmod +x 设置挂钩文件的执行权限。” (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html)。我的问题是:我该怎么做?
我只是将 .sh 文件放在一个目录中。我不会从其他任何地方调用它。我缺少一个简单的步骤吗?AWS 文档让它看起来应该很简单。
以前的尝试
我尝试过的事情:
- 添加 .ebextensions
- 尝试:使用以下命令在目录中创建一个
.config
文件,该文件应以 chmod +x 权限执行 .sh 文件。.ebextensions
- 结果:出现同样的错误。Elastic Beanstalk 日志根本不表示
.config
已处理。
- 尝试:使用以下命令在目录中创建一个
container_commands:
01_chmod1:
command: "chmod +x .platform/hooks/prebuild/01_installations.sh"
- 更改 .sh 文件的名称
- 尝试:按照 AWS 用户的建议将 .sh 文件命名为“chmod +x 01_installations.sh”(下面的论坛链接)。删除 .ebextensions
- 结果:出现同样的错误。
[RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/chmod +x 01_installations.sh failed with error fork/exec .platform/hooks/prebuild/chmod +x 01_installations.sh: permission denied
我在这里回顾了这些想法,但它们实际上都没有包含足够完整的示例来遵循: