AWS Lambda和Symfony Bref-部署Symfony 4网站

时间:2019-09-02 18:47:16

标签: php amazon-web-services symfony aws-lambda bref

我想借助AWS Lambda和Symfony Bref来部署我的Symfony 4网站,我遵循此文档:

但是我有这个错误:

enter image description here

我的serverless.yaml文件:

service: bref-symfony

package:
    exclude:
        - node_modules/**
        - venv/**

provider:
    name: aws
    region: eu-west-3
    runtime: provided
    environment:
        # Symfony environment variables
        APP_ENV: prod

plugins:
    - ./vendor/bref/bref

functions:
    website:
        handler: public/index.php
        timeout: 30 # in seconds (API Gateway has a timeout of 30 seconds)
        layers:
            - ${bref:layer.php-73-fpm}
        events:
            -   http: 'ANY /'
            -   http: 'ANY /{proxy+}'
    console:
        handler: bin/console
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-73} # PHP
            - ${bref:layer.console} # The "console" layer

请问是什么问题?

1 个答案:

答案 0 :(得分:0)

您似乎需要减少应用图片中包含的内容。确保您在composer上运行的是仅限生产的依赖项:

composer inst --no-dev -o

您还可以将以下内容添加到serverless.yaml中,以仅包括运行Symfony应用所需的文件:

package:
    exclude:
        - '*'
        - '**'
    include:
        - 'bin/**'
        - 'config/**'
        - 'public/index.php'
        - 'src/**'
        - 'var/cache/prod/**'
        - 'translations/**'
        - 'vendor/**'
        - '.env'