Search code examples
google-app-enginegoogle-cloud-platformgoogle-app-engine-php

Google App Engine standard - composer update --lock | Allowed memory size exhausted | Error 255


we have a PHP - Symfony project that we would like to run on Google Cloud App Engine Standard but we cannot deploy the app using gcloud app deploy app.yml because the build fails.

app.yml

runtime: php
service: "papi-dev"
instance_class: F2
env_variables:
  APP_ENV: prod
  APP_DEBUG: true
  DATABASE_URL: mysql://p...
runtime_config:
  document_root: ./public
  front_controller_file: index.php
  enable_stackdriver_integration: true
handlers:
# Declare the build and bundles directory as static assets to be served by the
# App Engine CDN.
- url: /build
  static_dir: public/build

composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "7.2.*",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "api-platform/api-pack": "^1.1",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "friendsofsymfony/elastica-bundle": "^5.0",
        "friendsofsymfony/oauth-server-bundle": "^1.6",
        "friendsofsymfony/user-bundle": "^2.1",
        "google/apiclient": "^2.0",
        "google/cloud-error-reporting": "^0.12.1",
        "google/cloud-logging": "^1.14",
        "guzzlehttp/guzzle": "~6.0",
        "jms/serializer-bundle": "^2.4",
        "lexik/jwt-authentication-bundle": "^2.5",
        "nelmio/cors-bundle": "^1.5",
        "pear/net_dns2": "^1.4",
        "productsupcom/jenkins-php-api": "^0.1.4",
        "sendgrid/sendgrid": "^7.2",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/expression-language": "*",
        "symfony/flex": "^1.1",
        "symfony/framework-bundle": "*",
        "symfony/lock": "4.1.*",
        "symfony/maker-bundle": "^1.7",
        "symfony/monolog-bundle": "^3.3",
        "symfony/orm-pack": "^1.0",
        "symfony/proxy-manager-bridge": "*",
        "symfony/templating": "4.1.*",
        "symfony/translation": "4.2.*",
        "symfony/yaml": "*",
        "webonyx/graphql-php": "^0.12.6",
        "wisembly/elephant.io": "^3.3"
    },
    "require-dev": {
        "symfony/phpunit-bridge": "4.1.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "4.2.*"
        }
    }
}

builder log

Step #1 - "builder": INFO composer_update_lock composer update --lock
Step #1 - "builder": INFO `composer_update_lock` stdout:
Step #1 - "builder": 
Step #1 - "builder": Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 9437184 bytes) in phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php on line 565
Step #1 - "builder": 
Step #1 - "builder": Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
Step #1 - "builder": INFO `composer_update_lock` had stderr output:
Step #1 - "builder": Do not run Composer as root/super user! See https://getcomposer.org/root for details
Step #1 - "builder": Loading composer repositories with package information
Step #1 - "builder": Updating dependencies (including require-dev)
Step #1 - "builder": Package operations: 128 installs, 0 updates, 0 removals
Step #1 - "builder": - Installing symfony/flex (v1.1.8): Downloading (connecting...)Downloading (0%) Downloading (20%)Downloading (25%)Downloading (45%)Downloading (60%)Downloading (65%)Downloading (75%)Downloading (80%)Downloading (90%)Downloading (95%)Downloading (100%)
Step #1 - "builder": 
Step #1 - "builder": ERROR error: `composer_update_lock` returned code: 255

The deploy command used to work until we've added more packages to composer.json. Best guess I have so far is that the build stopped working because of this github commit to the cloud builder image which executes composer update --lock upon every deploy/build execution.


Solution

  • Solved by Google - composer install is called instead of composer update.