超出 App Engine 部署作曲家内存限制
App Engine deploy composer memory limit exceeded
最近除了 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"
]
}
}
另外,当我在云构建期间收到此警告时,是否有机会将作曲家更新到 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,同样的问题
由于您部署的应用程序已经有一个从 App Engine 部署生成的 composer.lock
文件,默认情况下,App Engine 缓存获取的依赖项以减少构建时间。它会阻止您自动获取最新版本的依赖项,您将遇到错误:
You are using an outdated version of Composer
要解决此问题,运行 在本地命令 composer install
将您的依赖项固定到当前版本,并在 [=10= 时有 composer.lock
和 composer update
] 是 现有 。然后使用命令 'gcloud beta app deploy --no-cache' 进行部署以安装依赖项的未缓存版本。
最近除了 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"
]
}
}
另外,当我在云构建期间收到此警告时,是否有机会将作曲家更新到 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,同样的问题
由于您部署的应用程序已经有一个从 App Engine 部署生成的 composer.lock
文件,默认情况下,App Engine 缓存获取的依赖项以减少构建时间。它会阻止您自动获取最新版本的依赖项,您将遇到错误:
You are using an outdated version of Composer
要解决此问题,运行 在本地命令 composer install
将您的依赖项固定到当前版本,并在 [=10= 时有 composer.lock
和 composer update
] 是 现有 。然后使用命令 'gcloud beta app deploy --no-cache' 进行部署以安装依赖项的未缓存版本。