who*_*ate 12 hook chmod amazon-elastic-beanstalk ebextensions
语境
我正在使用 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
Run Code Online (Sandbox Code Playgroud)
题
我的理解是权限被拒绝,因为我没有添加chmod +x
以使 .sh 文件可执行。正如 AWS 平台挂钩文档所述:“使用 chmod +x 设置挂钩文件的执行权限。” (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html)。我的问题是:我该怎么做?
我只是在一个目录中有 .sh 文件。我不会从其他任何地方调用它。我错过了一个简单的步骤吗?AWS 文档使它看起来应该很简单。
以前的尝试
我尝试过的事情:
.config
在.ebextensions
目录中创建一个文件,该文件应该使用 chmod +x 权限执行 .sh 文件。.config
已处理。container_commands:
01_chmod1:
command: "chmod +x .platform/hooks/prebuild/01_installations.sh"
Run Code Online (Sandbox Code Playgroud)
[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
Run Code Online (Sandbox Code Playgroud)
我已经回顾了这里的想法,但实际上没有一个包含足够完整的示例来遵循:
确保您的文件在 git 中可执行
chmod +x path/to/file
git update-index --chmod=+x path/to/file
Run Code Online (Sandbox Code Playgroud)
通常,您在本地工作站上设置权限在压缩部署包之前在。
但是,如果您想在 EB 实例上执行此操作,则不能container_commands
用于此目的。其原因是,container_commands
执行之后 prebuild
。相反,您应该尝试使用commands
:
预构建文件在运行任何配置文件的命令部分中的命令之后和运行 Buildfile 命令之前运行。
归档时间: |
|
查看次数: |
3092 次 |
最近记录: |