Skip to content
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

feat: update docker images and add support for different architectures #1755

Merged

Conversation

BenjaminBergerM
Copy link
Contributor

@BenjaminBergerM BenjaminBergerM commented Feb 3, 2024

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 serverless/serverless#10797 (comment) 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):

@BenjaminBergerM BenjaminBergerM force-pushed the update-docker-image-source branch 2 times, most recently from 1a3b0da to 7390daa Compare February 3, 2024 21:45
@BenjaminBergerM BenjaminBergerM changed the title WIP: Update docker image source Draft: Update docker image source Feb 3, 2024
@BenjaminBergerM BenjaminBergerM force-pushed the update-docker-image-source branch 2 times, most recently from 676f9fd to 8be74c3 Compare February 3, 2024 21:56
@BenjaminBergerM BenjaminBergerM changed the title Draft: Update docker image source Update docker image source Feb 3, 2024
Copy link

@jomp16 jomp16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@@ -0,0 +1,33 @@
import { supportedRuntimesArquitecture } from "../../config/index.js"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not run because of this line, it should be changed to

import { supportedRuntimesArquitecture } from "../../../config/supportedRuntimes.js"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just changed this, sorry for the issue.

@BenjaminBergerM
Copy link
Contributor Author

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.

@manfioLP
Copy link

manfioLP commented Feb 5, 2024

apparently this would solve a lot of issues
#1754
#1750
other issues mentioned on serverless repos too

@BenjaminBergerM BenjaminBergerM changed the title Update docker image source Docker Support - update docker image source Feb 5, 2024
@LeoNero
Copy link

LeoNero commented Feb 6, 2024

Tested with a project using golang, provided.al2, and an M1 Mac and it seems to work well. No errors found so far.

@ncostamagna
Copy link

I am testing in Go and it works!

@dOrgJelli
Copy link

Tested this using python3.10 functions on linux and works great, thank you for this fix!

@BenjaminBergerM
Copy link
Contributor Author

@dnalborczyk i just fix the lint error, can run again the actions workflow?

@dnalborczyk
Copy link
Collaborator

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

async request(event) {
const url = `http://${this.#dockerOptions.host}:${this.#port}/2015-03-31/functions/${this.#functionKey}/invocations`
const url = `http://${this.#dockerOptions.host}:${this.#port}/2015-03-31/functions/function/invocations`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ${this.#functionKey} not working here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the aws images, to invoke a function is no need to use the function key.

https://docs.aws.amazon.com/lambda/latest/dg/go-image.html#go-image-clients

Heres an example on the documentation.

Screenshot 2024-02-10 at 18 50 03

@BenjaminBergerM
Copy link
Contributor Author

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!

@LuidmilaDezhkina
Copy link

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?

@DorianMazur
Copy link
Collaborator

DorianMazur commented Apr 20, 2024

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) -> aws/aws-lambda-base-images#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 -> serverless/serverless#12348

@DorianMazur
Copy link
Collaborator

DorianMazur commented Apr 23, 2024

Okay, it should be fixed now. I will wait for tests and probably merge it. Thank you @BenjaminBergerM

@DorianMazur DorianMazur changed the title Docker Support - update docker image source feat: update docker images and add support for different architectures Apr 23, 2024
@DorianMazur DorianMazur merged commit d6b155e into dherault:master Apr 23, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet