首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在本地运行无服务器的基本示例

无法在本地运行无服务器的基本示例
EN

Stack Overflow用户
提问于 2020-10-27 10:52:43
回答 1查看 581关注 0票数 2

我想运行一个基本的无服务器示例& bref示例。

我所做的:

  1. npm安装-g无服务器
  2. 作曲家要求
  3. 供应商/bin/bref init
  4. 无服务器调用本地-f hello -docker

我得到了这个错误:

代码语言:javascript
复制
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

代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-05 00:07:49

serverless invoke local尝试使用一个名为lambci/lambda:${runtime}的Docker映像,在您的示例中,runtimephpX.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

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64552880

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档