serverless-offline
serverless-offline copied to clipboard
Docker Support - update docker image source
Description
Since https://github.com/lambci/docker-lambda lambda docker images are deprecated, serverless offline using docker was not working with many languages. So I changes de docker image source from lambci/docker-lambda
to public.ecr.aws/lambda/{runtime}
.
Also added support to diffrent architectures, now works with all runtimes and architectures that aws has a public image con ecr.
Also change docker configuration so it could be run with the new images.
Follow https://github.com/serverless/serverless/issues/10797#issuecomment-1544922990 this instructions.
Motivation and Context
I have many services running with Serverless and Golang, i use this plugin to run them locally and since 29 of January i want able to run muy code.
Related issues: #1754 #1750
How Has This Been Tested?
I run all test, and also imported the package to deferent serverless applications i have using docker.
Screenshots (if appropriate):
It sorta works using java11 runtime after changing this import line, but still not 100% on first run.
On first run, calling some REST API, the runtime gives an error
✖ Failed to fetch from http://localhost:50257/2018-06-01/ping with Not Found
But when I request the same REST API, it works (and all subsequently requests)
On this aws docker images i could find ping endpoint, so i remove ping function.
apparently this would solve a lot of issues #1754 #1750 other issues mentioned on serverless repos too
Tested with a project using golang, provided.al2, and an M1 Mac and it seems to work well. No errors found so far.
I am testing in Go and it works!
Tested this using python3.10 functions on linux and works great, thank you for this fix!
@dnalborczyk i just fix the lint error, can run again the actions workflow?
thank you for the PR @BenjaminBergerM !
I just de-activated the docker tests because of the failures. I suppose we should activate those again. could you do this in this PR? https://github.com/dherault/serverless-offline/commit/0e883f75627d6d88297e0faf0e98b47e2e4a2499
thank you for the PR @BenjaminBergerM !
I just de-activated the docker tests because of the failures. I suppose we should activate those again. could you do this in this PR? 0e883f7
Hi @dnalborczyk, thanks you for the review!
I rebase the branch and activated the tests you de-activate previously.
Waiting for the final review!
Hello everyone! I want to express my appreciation for your PR contributions. While deploying the code to the cloud seems to be successful, I've encountered an error locally: '/lambda-entrypoint.sh: line 14: /var/runtime/bootstrap: No such file or directory.' Interestingly, I can see that the zip file was unpacked, and for each invocation, I can locate it at a path similar to '../.serverless-offline/...../fe9fdf79-23ca-49d6-9d1c-162876a7960b/code/bootstrap.' Any insights on what might be causing this issue?
There are some issues on ubuntu:
× 19 Apr 2024 19:54:44,280 [INFO] (rapid) INIT START(type: on-demand, phase: init)
19 Apr 2024 19:54:44,280 [INFO] (rapid) The extension's directory "/opt/extensions" does not exist, assuming no extensions to be loaded.
19 Apr 2024 19:54:44,280 [INFO] (rapid) Starting runtime without AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN , Expected?: false
Warning: Apr 2024 19:54:44,281 [WARNING] (rapid) First fatal error stored in appctx: Runtime.InvalidEntrypoint
19 Apr 2024 19:54:44,281 [INFO] (rapid) INIT RTDONE(status: error)
19 Apr 2024 19:54:44,281 [INFO] (rapid) INIT REPORT(durationMs: 0.416000)
Error: 19 Apr 2024 19:54:44,281 [ERROR] (rapid) Init failed error=fork/exec /var/runtime/bootstrap: no such file or directory InvokeID=
Warning: Apr 2024 19:54:44,281 [WARNING] (rapid) Shutdown initiated: spindown
19 Apr 2024 19:54:44,281 [INFO] (rapid) Waiting for runtime domain processes termination
19 Apr 2024 19:54:44,281 [INFO] (rapid) INIT START(type: on-demand, phase: invoke)
19 Apr 2024 19:54:44,281 [INFO] (rapid) The extension's directory "/opt/extensions" does not exist, assuming no extensions to be loaded.
19 Apr 2024 19:54:44,281 [INFO] (rapid) Starting runtime without AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN , Expected?: false
Warning: Apr 2024 19:54:44,281 [WARNING] (rapid) First fatal error stored in appctx: Runtime.InvalidEntrypoint
19 Apr 2024 19:54:44,281 [INFO] (rapid) INIT RTDONE(status: error)
19 Apr 2024 19:54:44,281 [INFO] (rapid) INIT REPORT(durationMs: 0.298000)
19 Apr 2024 19:54:44,281 [INFO] (rapid) INVOKE START(requestId: cd2d4f30-d5ad-4f38-bd05-bc9574b90d13)
Error: 19 Apr 2024 19:54:44,281 [ERROR] (rapid) Invoke failed error=fork/exec /var/runtime/bootstrap: no such file or directory InvokeID=cd2d4f30-d5ad-4f38-bd05-bc9574b90d13
Error: 19 Apr 2024 19:54:44,281 [ERROR] (rapid) Invoke DONE failed: Runtime.InvalidEntrypoint
Warning: Apr 2024 19:54:44,281 [WARNING] (rapid) Reset initiated: ReleaseFail
19 Apr 2024 19:54:44,281 [INFO] (rapid) Waiting for runtime domain processes termination
Maybe this issue is related, it's hard to say (I need to dig deeper) -> https://github.com/aws/aws-lambda-base-images/issues/26
There is also another alternative to lambci/lambda images (but they are not official docker images) -> https://github.com/mLupine/docker-lambda Someone created a PR with mLupine/docker-lambda images for a serverless repo -> https://github.com/serverless/serverless/pull/12348
Okay, it should be fixed now. I will wait for tests and probably merge it. Thank you @BenjaminBergerM