New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing provided runtime to work. #648
Conversation
That works so well, thank you @atrope! Here is an example:
This change is quite small, hopefully it should be safe to merge :) @atrope there is however a small conflict to fix for the PR to be mergeable. Folks at https://github.com/brefphp/bref are eager to migrate from SAM to Serverless and this plugin is the last missing piece. |
update from master
hey @atrope sorry for not having followed up on this. if I remember correctly, the problem is that the "provided" option already (kind of) works (or, at least, it's being ignored and uses whatever runtime is specified in a separate custom parameter: providedRuntime) that would probably break that functionality with the current PR. I wonder if we should introduce a custom parameter, and have it not tied to provided runtimes? since it's mainly used to invoke that proxy handler, which I assume was meant for python and ruby, and those are determined by the provider.runtime option, for which thinking about it, what we could do maybe is to add docker as a providedRuntime option? e.g. providedRuntime: docker that would give us also an escape route for a possible future "provided runtime" implementation (which is not tied to docker, or any container technology). |
@dnalborczyk maybe I understand things wrong, but with what you suggest we would have to set an extra option to make it work? What is the need behind those not-actually-provided runtimes? I've tried reading the code and the discussions but I can't get my head around it. |
hey @mnapoli no problem. let me explain (keep in mind I don't know Python or Ruby, so everything below is from the point of view of a node.js user): before provided runtimes (and custom layers) were a thing, # serverless.yml
provider:
runtime: nodejs8.10 # or: python3.7 / ruby2.5 etc.
now enter provided runtimes: # serverless.yml
provider:
runtime: provided
# serverless.yml
provider:
runtime: provided
custom:
serverless-offline:
providedRuntime: nodejs in that case if we merge the PR as is, to circumvent this problem, and still give people to run a custom docker container, I thought instead of adding yet another additional custom parameter, we re-use the providedRuntime parameter for this purpose, e.g.: # serverless.yml
provider:
runtime: provided
custom:
serverless-offline:
providedRuntime: docker in that case, does that clear it up a bit? @mnapoli |
from a node.js developer perspective: I can keep using the current setup: "native" node. easier development, debugging, etc. why then use I heard also rumors that provided runtimes will be the way to go and aws supported runtimes will eventually be phased out. but if that will ever happen I guess time will tell. |
on a different note, since I read through your issue: brefphp/bref#320 it might as well be possible to add that is not to say we shouldn't pull in this PR, which would still support essentially anything running on docker (not only PHP). |
Or you could implement the PHP runtime for serverless-offline, similar to Python and Ruby. |
@dnalborczyk thank you very much for all the explanation, that makes much more sense now!
Do you think it would solve the problem here?
Python and Ruby and runtimes officially supported by |
826a135
to
d0695ce
Compare
Closing because 1yo now. |
Really sad to see this not make it in. Would be a great feature. |
This fixed my problem provider:
name: aws
runtime: provided
custom:
serverless-offline:
useDocker: true #this enables the use of docker and downloads your layers
functions:
web:
handler: handler.hello
events:
- http:
path: /{any+} # this matches any path, the token 'any' doesn't mean anything special
method: ANY
layers:
- arn:aws:lambda:ap-southeast-2:239930134035:layer:node-14-runtime:9 #add your custom layer here |
This should fix #570
How to test:
YML:
index.php:
Can be anything for example:
Hello <?php echo $_GET['name'] ?? "World";?>
sls offline will work now.
This is a first approach.
I see lots of ways to improve like reusing the same container and not having to rebuild each and every request.
Comments and tests with another layers are always welcome.