Невозможно запустить локально базовый пример без сервера и bref

Я хочу запустить простой пример безсерверного и bref.

Что я сделал:

  1. npm install -g serverless
  2. композитор требует bref/bref
  3. поставщик /bin/bref init
  4. безсерверный вызов local -f hello --docker

Я получаю эту ошибку:

Miroslavs-MacBook-Air:testing kosta90s$ serverless invoke local -f hello --docker
Serverless: Packaging service...
Serverless: Excluding development dependencies...
START RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2 Version: $LATEST
END RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2
REPORT RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2  Init Duration: 15.78 ms Duration: 1.35 ms   Billed Duration: 100 ms Memory Size: 1024 MB    Max Memory Used: 7 MB   

{"errorType":"exitError","errorMessage":"RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2 Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"}
 
  Error --------------------------------------------------
 
  Error: Failed to run docker for provided image (exit code 1})
      at /usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:536:21
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.14.0
     Framework Version:         2.8.0
     Plugin Version:            4.1.1
     SDK Version:               2.3.2
     Components Version:        3.2.7

serverless.yml

service: app

provider:
    name: aws
    region: us-east-1
    runtime: provided

plugins:
    - ./vendor/bref/bref

functions:
    hello:
        handler: index.php
        description: ''
        layers:
            - ${bref:layer.php-74}

# Exclude files from deployment
package:
    exclude:
        - 'tests/**'

Я работаю над MacOs Catalina.

1 ответ

Решение

serverless invoke local пытается использовать образ Docker с именем lambci/lambda:${runtime} где runtime является phpX.Y в твоем случае.

https://github.com/serverless/serverless/blob/6a81137406fd2a2283663af93596ba79d23e38ef/lib/plugins/aws/invokeLocal/index.js#L478

Нет такого изображения, которое вы можете увидеть здесь:

https://hub.docker.com/r/lambci/lambda/tags

Как сказано в комментариях, попробуйте без --docker. Если вам нужен Docker, вы можете следовать документации и использовать следующие docker-compose.yml:

version: "3.5"

services:
    web:
        image: bref/fpm-dev-gateway
        ports:
            - '8000:80'
        volumes:
            - .:/var/task
        depends_on:
            - php
        environment:
            HANDLER: index.php
    php:
        image: bref/php-74-fpm-dev
        volumes:
            - .:/var/task:ro
Другие вопросы по тегам