运行相同的钩子进行部署和配置部署

Jul*_* B. 7 elastic-beanstalk

将 Elastic Beanstalk 与 Amazon Linux 2 结合使用,我尝试为部署(代码部署)和配置部署执行相同的挂钩,而不必在两个不同的位置复制我的代码。

\n

根据AWS文档, eb将在.platform/hooks/prebuild部署初始步骤中运行挂钩,但将在.platform/confighooks/prebuild,但在配置部署时将运行挂钩。

\n

我的文件看起来像这样。

\n
.platform\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hooks\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 prebuild\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 00_hookname.sh\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 01_hookname.sh\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 99_basic_auth.sh\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 httpd\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 conf.d\n        \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 elasticbeanstalk\n            \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 directory.conf\n            \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hardening.conf\n            \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 headers.conf\n
Run Code Online (Sandbox Code Playgroud)\n

我正在尝试找到一种方法来运行 99_basic_auth.sh 进行部署配置部署,而无需复制该代码。

\n

我有什么办法可以实现这一目标吗?

\n

干杯!

\n

Jul*_* B. 5

我发现执行此类操作的最简单方法是简单地从第二个脚本调用第一个脚本。

\n
.platform\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hooks\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 prebuild\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 00_hookname.sh\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 01_hookname.sh\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 99_basic_auth.sh\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 confighooks\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 prebuild\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 99_basic_auth.sh\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 httpd\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 conf.d\n        \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 elasticbeanstalk\n            \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 directory.conf\n            \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hardening.conf\n            \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 headers.conf\n
Run Code Online (Sandbox Code Playgroud)\n

内容在哪里.platform/confighooks/prebuild/99_basic_auth.sh是:

\n
#!/bin/bash\n\nset -e\n\n/bin/bash "/var/app/current/.platform/hooks/prebuild/99_basic_auth.sh"\n
Run Code Online (Sandbox Code Playgroud)\n