【发布时间】:2020-10-28 21:54:21
【问题描述】:
最近除了 app.yaml 中的环境变量之外没有任何代码更改,应用引擎部署在云构建过程中失败,超出内存限制,我不明白我在哪里可以更改它,或者为什么它会成为问题.. . 我尝试设置“gcp-build”来覆盖composer install 命令,但在云构建过程中出现此错误:
Step #3 - "detector": ======== Output: google.php.composer-gcp-build@0.9.0 ========
Step #3 - "detector": unmarshalling composer.json: json: cannot unmarshal array into Go struct field composerScriptsJSON.scripts.gcp-build of type string [id:070ec49f]
Step #3 - "detector": ======== Results ========
这是我的 composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"google/cloud": "^0.142.0",
"google/cloud-core": "^1.39",
"google/cloud-error-reporting": "^0.18.0",
"google/cloud-firestore": "^1.14",
"google/cloud-logging": "^1.21",
"guzzlehttp/guzzle": "^7.0.1",
"intervention/image": "^2.5",
"kreait/firebase-php": "^5.0",
"kreait/firebase-tokens": "^1.10",
"kreait/laravel-firebase": "^2.2",
"kyslik/column-sortable": "^6.3",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0",
"owen-it/laravel-auditing": "^10.0",
"predis/predis": "^1.1",
"propaganistas/laravel-phone": "^4.2",
"superbalist/laravel-google-cloud-storage": "^2.2",
"tymon/jwt-auth": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^9.0",
"nunomaduro/collision": "^5.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"classmap": [
"database/seeders",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"composer dump-autoload",
"php artisan optimize",
"chmod -R 755 bootstrap\/cache",
"php artisan migrate --no-interaction --force"
],
"gcp-build": [
"COMPOSER_MEMORY_LIMIT=-1 composer install --no-dev"
]
}
}
另外,当我在云构建期间收到此警告时,是否有机会将 composer 更新到 v2:
Step #6 - "builder": Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
这是构建失败的实际问题:
Step #6 - "builder": Updating dependencies
Step #6 - "builder":
Step #6 - "builder": Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Step #6 - "builder":
Step #6 - "builder": Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.Done "composer install --no-dev --no-progress --no-suggest --no-in..." (56.105751566s)
Step #6 - "builder": Failure: (ID: 5888fcc4) Loading composer repositories with package information
Step #6 - "builder": Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Step #6 - "builder": Updating dependencies
Step #6 - "builder":
Step #6 - "builder": Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Step #6 - "builder":
Step #6 - "builder": Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
app.yaml 中使用的运行时是 php74,也尝试将其更改为 php72,同样的问题
【问题讨论】:
-
如果您的应用程序文件夹中没有 composer.lock 文件,请尝试运行命令
composer install,如果 composer.lock 存在,请尝试运行composer update。然后,使用命令gcloud app deploy --no-cache部署您的应用程序,以确保更新依赖项。 -
@john-michael-g 谢谢!它确实有帮助
-
我认为这样做可以解决您的问题
标签: google-app-engine google-cloud-platform google-cloud-build