dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 796 forks source link

Docker containers do not start automatically with flag --useDocker #1664

Open fedevilensky opened 1 year ago

fedevilensky commented 1 year ago

Bug Report

Current Behavior When I run sls offline --useDocker start Lambda times out, because it does not launch docker containers, errors out with the following message

ANY /hello (λ: hello)
✖ 2023/02/24 17:59:44 open /var/task/testdata/docker-volumes/postgrsql/data: permission denied

✖ 2023/02/24 17:59:45 Mock server did not start in time

✖ [504] - Lambda timeout.
frameworkVersion: "3"

service: my-service

plugins:
  - serverless-offline

provider:
  name: aws
  runtime: go1.x
  httpApi:
    cors: true

functions:
  hello:
    events:
      - http:
          method: *
          path: hello
    handler: bin/hello
package main

import (
    "context"

    "github.com/aws/aws-lambda-go/events"
)

func Handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
    return events.APIGatewayProxyResponse{Body: req.Body, StatusCode: 200}, nil
}

Expected behavior/code

The docker containers start automatically and the lamdas don't timeout

Environment

codedge commented 1 year ago

I am having the same problem on MacOS.

My YAML file:

plugins:
  - serverless-offline

service: abc

app: abc
org: codedge

frameworkVersion: "3"

provider:
  name: aws
  runtime: go1.x

package:
  patterns:
    - "!./**"
    - ./bin/**

functions:
  airmail:
    handler: bin/abc
    events:
      - httpApi:
          path: /
          method: post

Error

{
    "errorMessage": "[504] - Lambda timeout.",
    "errorType": "LambdaTimeoutError",
    "stackTrace": [
        "Error: [504] - Lambda timeout.",
        "at #timeoutAndTerminate (file:///Users/holger/code/hedge10/airmail-infra/node_modules/serverless-offline/src/lambda/LambdaFunction.js:283:11)",
        "at async LambdaFunction.runHandler (file:///Users/holger/code/hedge10/airmail-infra/node_modules/serverless-offline/src/lambda/LambdaFunction.js:305:16)",
        "at async file:///Users/holger/code/hedge10/airmail-infra/node_modules/serverless-offline/src/events/http/HttpServer.js:602:18",
        "at async exports.Manager.execute (/Users/holger/code/hedge10/airmail-infra/node_modules/@hapi/hapi/lib/toolkit.js:60:28)",
        "at async internals.handler (/Users/holger/code/hedge10/airmail-infra/node_modules/@hapi/hapi/lib/handler.js:46:20)",
        "at async exports.execute (/Users/holger/code/hedge10/airmail-infra/node_modules/@hapi/hapi/lib/handler.js:31:20)",
        "at async Request._lifecycle (/Users/holger/code/hedge10/airmail-infra/node_modules/@hapi/hapi/lib/request.js:370:32)"
    ]
}
kubenstein commented 4 months ago

i had same issue and the solution was to set much bigger timeout for lambdas. Looks like the timeout blocks pulling docker image.