GCP内存部署symfony

时间:2019-07-15 16:08:41

标签: composer-php out-of-memory gcloud

我是GCP的新手,我正在尝试部署Symfony 4应用程序,但在composer安装时出现内存消息错误。 我正在使用App Engine Flex。

Step #1: Package operations: 115 installs, 0 updates, 0 removals
Step #1:   - Installing ocramius/package-versions (1.4.0): Loading from cache
Step #1: The following exception is caused by a lack of memory or swap, or not having swap configured
Step #1: Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
Step #1: 
Step #1: PHP Warning:  proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 952
Step #1: 
Step #1: Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 952
Step #1:                                                      
Step #1:   [ErrorException]                                   
Step #1:   proc_open(): fork failed - Cannot allocate memory  
Step #1:                                                      
Step #1: 
Step #1: install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
Step #1: 
Step #1: error building image: error building stage: waiting for process to exit: exit status 1
Finished Step #1

这是我的app.yaml

runtime: php
env: flex

resources:
  memory_gb: 4

runtime_config:
  document_root: public

env_variables:
  APP_ENV: prod
  APP_SECRET: secret
  # APP_DEBUG: true

  ## For connecting to Cloud SQL with Doctrine
  ## This is used in part two of the README:
  # DATABASE_URL: mysql://root:DB_PASSWORD@localhost?unix_socket=/cloudsql/INSTANCE_CONNECTION_NAME;dbname=symfonydb

handlers:
  # Declare the build and bundles directory as static assets to be served by the
  # App Engine CDN.
  - url: /build
    static_dir: public/build
  - url: /bundles
    static_dir: public/bundles
  - url: /js
    static_dir: public/js

  # Declare any media files in the public directory as static assets as well.
  - url: /(.*\.(ico|txt|gif|png|jpg))$
    static_files: public/\1
    upload: public/.*\.(ico|txt|gif|png|jpg)$

我试图设置memory_gb参数,但是没有效果。 如何增加内存?

谢谢

1 个答案:

答案 0 :(得分:0)

我已经解决了我的问题。 它包含了我的composer.lock(是的,我在.gloudignore文件中忽略了它)。

但是,如果问题仍然存在,请考虑COMPOSER_MEMORY_LIMIT环境变量,也许会有所帮助。

而且,如果仍然无法正常运行,则可能是Compute Engine而不是App Engine或您自己的Dockerfile进行部署。

相关问题