如何在 Elastic Beanstalk 自定义平台中更改 container_command 的工作目录

如何在 Elastic Beanstalk 自定义平台中更改 container_command 的工作目录

container_command应用程序的 .ebextensions 中定义的要执行的工作目录位于/tmp示例自定义平台上Node平台_Ubuntu,而我预计它是暂存目录,如这个文件

如何将工作目录更改为暂存目录(解压源代码的根目录)?

这是.ebextensions/foo.config测试应用程序查看的工作目录。

container_commands:
  10-test:
    command: env

那么,这是它在 /var/log/eb-activity.log 中的输出。

[2018-04-30T04:26:54.394Z] INFO  [19153] - [Application update test-app-4@4/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_cocci_custom_eb_test/Command 10-test] : Starting activity...
[2018-04-30T04:26:54.399Z] INFO  [19153] - [Application update test-app-4@4/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_cocci_custom_eb_test/Command 10-test] : Completed activity. Result:
  PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
  PWD=/tmp
  SHLVL=1
  HOME=/root
  EB_IS_COMMAND_LEADER=true
  _=/usr/bin/env

[2018-04-30T04:26:54.618Z] INFO  [19153] - [Application update test-app-4@4/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_cocci_custom_eb_test/Command 20-check-process] : Starting activity...

答案1

我可以通过在自定义平台的 platform.yaml 文件中指定它来更改它。

container:
  app_staging_dir: "/var/app/staging"

container_command的日志;

[2018-04-30T09:49:14.452Z] INFO  [1482]  - [Application deployment test-app-4@2/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_cocci_custom_eb_test/Command 10-test] : Completed activity. Result:
  PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
  PWD=/var/app/staging
  SHLVL=1
  HOME=/root
  EB_IS_COMMAND_LEADER=false
  _=/usr/bin/env

我猜测其他选项也可以用同样的方式指定。

ubuntu@ip-xxxxxx:~$ sudo /opt/elasticbeanstalk/bin/get-config container --output YAML
---
app_staging_dir: "/var/app/staging"
instance_port: '80'
config_staging_dir: "/tmp"
common_log_list:
- "/var/log/eb-activity.log"
log_group_name_prefix: "/aws/elasticbeanstalk"
source_bundle: "/opt/elasticbeanstalk/deploy/appsource/source_bundle"

相关内容