dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.16k stars 794 forks source link

Add ruby3.2 runtime #1732

Closed jeremiahlukus closed 2 months ago

jeremiahlukus commented 10 months ago

Description

Add ruby3.2 runtime.

Motivation and Context

This is required to run ruby 3.2 or you get unsupported runtime. Since ruby2.7 is deprecated in Dec 7, 2023 I just replaced with ruby3.2 instead of adding a ruby 3.2 folder in the tests.

How Has This Been Tested?

I ran npm test locally and in the workflow. I then tested on a local app and its running without issues.

Screenshots (if appropriate):

Screenshot 2023-09-09 at 11 47 55 PM
jeremiahlukus commented 10 months ago

A test failed in ci I’ll fix one moment

jeremiahlukus commented 10 months ago

After some testing i found https://github.com/lambci/docker-lambda is now moved to ecr https://gallery.ecr.aws/lambda/ruby.

For now I will leave the ruby2.7 docker test. In another PR I will migrate to use ecr, but this is out of scope for this PR.

dereke commented 10 months ago

After some testing i found https://github.com/lambci/docker-lambda is now moved to ecr https://gallery.ecr.aws/lambda/ruby.

For now I will leave the ruby2.7 docker test. In another PR I will migrate to use ecr, but this is out of scope for this PR.

I think you could change this line to be something like:

  if (runtime.indexOf('ruby:') == 0) {
    return `amazon/aws-lambda-${runtime}`

  } else {
    return `lambci/lambda:${runtime}`
  }

I'm not sure if that repo has all the other required images.

(thanks for picking this up BTW - I've just run into it myself)

jeremiahlukus commented 10 months ago

ok added

EDIT:

its still broken ill message when done

jeremiahlukus commented 10 months ago

I am unable to get it to work in docker it spins up the img

Screenshot 2023-09-10 at 2 25 58 PM

But gets stuck.

Screenshot 2023-09-10 at 2 26 23 PM

Ive spent a few hours on it but i think this belongs in a different PR.

some notes: You might have to run docker logout

  #baseImage(runtime) {
    // The new docker img has to be pulled like:
    // docker pull amazon/aws-lambda-ruby:3.2
    // so we must split the string at the first occurance of a number
    const splitRuntime = runtime.split(/(\d.*)/, 2)
    return `amazon/aws-lambda-${splitRuntime[0]}:${splitRuntime[1]}`
  }

im going to revert the docker code for now.

DorianMazur commented 2 months ago

@jeremiahlukus I think that this PR can be closed. serverless-offline already supports ruby 3.2