serverless-offline
serverless-offline copied to clipboard
Docker containers do not start automatically with flag --useDocker
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.
- file: serverless.yml
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
- file: cmd/hello.go
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
-
serverless
version: 3.27.0 -
serverless-offline
version: ^12.0.4, -
go
version: 1.20.1 -
OS
: Arch 6.1.12-arch1-1
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)"
]
}
i had same issue and the solution was to set much bigger timeout
for lambdas. Looks like the timeout blocks pulling docker image.