lambci / docker-lambda

Docker images and test runners that replicate the live AWS Lambda environment
MIT License
5.83k stars 431 forks source link

can not find the executable file `Deno` #277

Closed davidxiao closed 4 years ago

davidxiao commented 4 years ago

Hello, I tried to run custom runtime with Deno(https://github.com/hayd/deno-lambda/releases/download/1.0.2/deno-lambda-example.zip), while failed saying the below errors: 111 #### PATH=/var/task/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin 222 #### pwd=/var/task /var/task/bootstrap: line 238: deno: command not found

I feel PATH, and current directory are correct, and deno is under /var/task/bin directory Any idea why it happens?

mhart commented 4 years ago

That example just has a hello.ts file – where are you expecting deno to come from?

mhart commented 4 years ago

This works for me:

  1. Download deno-lambda-layer.zip and unzip
  2. Download deno-lambda-example.zip and unzip
  3. cd into deno-lambda-layer
  4. Run:
docker run --rm \
  -v "$PWD":/opt \
  -v "$PWD/../deno-lambda-example":/var/task \
  lambci/lambda:provided hello.handler

Lambda layers mount at /opt and handler code mounts at /var/task

davidxiao commented 4 years ago

hi, @mhart , thanks very much for so quick response, my bad, i had used all under /var/task, i got error when invoked(tried both of below): aws lambda invoke --endpoint http://localhost:9001 --no-sign-request --function-name deno-func --payload '{}' output.json

aws lambda invoke --endpoint http://localhost:9001 --no-sign-request \ --function-name myfunction --payload '{}' output.json

Could not connect to the endpoint URL: "http://localhost:9001/2015-03-31/functions/deno-func/invocations"

mhart commented 4 years ago

I can't see the command you're using to invoke docker-lambda. If you want to run in stay-open mode, you need to pass -e DOCKER_LAMBDA_STAY_OPEN=1 – are you doing that?

Function name doesn't matter – you can use what you like. The 2015-03-31 is from the Lambda API – that's the correct URL

davidxiao commented 4 years ago

I used the below command to start, then invoke it via the commands in previous comments docker run -d \ -e DOCKER_LAMBDA_STAY_OPEN=1 \ -v "$PWD":/opt \ -v "$PWD/../example":/var/task \ lambci/lambda:provided hello.handler

I can see the below message after start: Lambda API listening on port 9001...

then invoked it via: aws lambda invoke --endpoint http://localhost:9001 --no-sign-request --function-name deno-func --payload '{}' output.json

and got error:

aws lambda invoke --endpoint http://localhost:9001 --no-sign-request --function-name deno-func --payload '{}' output.json

mhart commented 4 years ago

Please see the example in the README: https://github.com/lambci/docker-lambda#running-in-stay-open-api-mode

You need to let docker know what ports you want to expose (eg, -p 9001:9001)

davidxiao commented 4 years ago

:(, thanks very much,

hayd commented 4 years ago

xlink to https://github.com/hayd/deno-lambda/issues/81#issuecomment-635763562

Lambda layers mount at /opt and handler code mounts at /var/task

Is key: you need the bin/deno binary mounted to /opt.