serverless-heaven / serverless-webpack

Serverless plugin to bundle your lambdas with Webpack
MIT License
1.72k stars 417 forks source link

refactor: ignore handlers with `image.name` property #1885

Open ilyesBen opened 3 months ago

ilyesBen commented 3 months ago

What did you implement:

Closes #1884

Ignoring the handlers with the the image.name property the same way the ones with image.uri are ignored as they are lambda containers.

How did you implement it:

How can we verify it:

Create a serverless template with both a lambda handler and a lambda container. The lambda container should have the image.name property poiting to an ecr image defined in the same template. The following example can be used:

service: converter

frameworkVersion: '3'

plugins:
  - serverless-webpack

custom:
  webpack:
    packager: yarn

package:
  individually: true

provider:
  name: aws
  ecr:
    images:
      image-test:
        path: ./

functions:
  functionHandler:
    handler: src/functions/funcionHandler.handler
    name: functionHandler-${sls:stage}

  functionContainer:
    name: functionContainer-${sls:stage}
    image:
      name:  image-test
      command:
        - 'functionContainer.handler'

Run serverless package

serverless package

The packager should not throw any error. It should package functionHandler and build the image test-image for the function functionContainer (you would need to make sure you have a valid Dockerfile in the root folder for the image to build).

output in master

Screenshot 2024-08-10 at 13 48 30

output in this branch

Screenshot 2024-08-10 at 13 49 54

Todos:

Is this ready for review?: YES Is it a breaking change?: NO

j0k3r commented 3 months ago

Could you fix failing tests? Thanks

ilyesBen commented 3 months ago

Could you fix failing tests? Thanks

Sure, I will look into it.

ilyesBen commented 1 month ago

Could you fix failing tests? Thanks

@j0k3r I have fixed test. I have removed all the checks around docker based functions as serverless-webpack should not attempt to compile them IMO. I hope it makes sense.