post-install-cmd 在 Google App Engine 柔性环境中不工作

post-install-cmd not working in Google App Engine Flexible Environment

我正在尝试通过 composer 的 post-install-cmd 更新文件权限,但在我看来它无法正常工作,尽管在日志中它说命令已正确执行但是当我登录到 VM 时它仍然显示不正确的权限。

这是我在 /composer.json

"scripts": {
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-install-cmd": [
        "chmod -R 777 public\/external_package\/webmail\/data"
    ]
}

这是我的 /app.yaml

runtime: php
env: flex

service: webservice-dev

runtime_config:
  document_root: public
  whitelist_functions: phpversion,phpinfo

env_variables:
  # Environment variables.
  APP_NAME: 'Laravel App (Dev)'
  APP_ENV: dev
  # ...
  # ...

beta_settings:
  cloud_sql_instances: ""

automatic_scaling:
  min_num_instances: 2
  max_num_instances: 10
  cpu_utilization:
    target_utilization: 0.50

resources:
  cpu: 1
  memory_gb: 4

这里是Cloud Build的截图

这就是我在 VM 中看到的内容

dr-xr-x--- 1 root www-data  4096 Jan 28 19:18 data

我希望此目录权限为 777 而不是 550

这是因为 App Engine 始终锁定文档根路径,因此权限被恢复。

将此添加到您的 app.yaml

runtime_config:
  skip_lockdown_document_root: true

选项 skip_lockdown_document_root: true 将防止更改权限。