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

serverless-webpack 5.5.0 attempts to run Webpack on container images which are not JavaScript #825

Closed
cnorthwood opened this issue May 12, 2021 · 13 comments · Fixed by #877
Labels
Milestone

Comments

@cnorthwood
Copy link

This is a Bug Report

Description

For bug reports:

  • What went wrong?

serverless-webpack is stopping me from deploying lambda containers as part of my service that are not

  • What did you expect should have happened?

it should not have touched them as they're not relevant to webpack

  • What was the config you used?

N/A

I assume this is related to #723, which I can see the sense in - however, I can't see a way to say "this isn't a container image that Webpack cares about" and hence ignore that lambda in the service definition. Ideally there'd be an option to opt in/out of either Webpack's involvement in particular functions, or container functions as a whole as not all container functions are guaranteed to be part of the service.

Additional Data

$ /Users/chris/Code/report-support/node_modules/.bin/serverless deploy -v --stage dev
Serverless: Using configuration:
{
  "webpackConfig": "api/webpack.config.js",
  "includeModules": {
    "forceInclude": [
      "pg"
    ]
  },
  "packager": "yarn",
  "keepOutputDirectory": true,
  "packagerOptions": {},
  "concurrency": 12
}
 
 Serverless Error ----------------------------------------
 
  No matching handler found for 'apollo' in 'XXX'. Check your service definition.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.16.1
     Framework Version:         2.41.1 (local)
     Plugin Version:            4.6.0
     SDK Version:               4.2.2
     Components Version:        3.9.2
@j0k3r
Copy link
Member

j0k3r commented May 12, 2021

For what I understand you are mixing both container and regular JavaScript function in the same serverless config?
Any chance to share a short config to reproduce?

@cnorthwood
Copy link
Author

service: report-support

provider:
  name: aws
  region: eu-west-2
  runtime: nodejs12.x
  stage: ${opt:stage, 'dev'}
  versionFunctions: false

plugins:
  - serverless-webpack

functions:
  server:
    image:
      uri: ${env:DOCKER_IMAGE}
      entryPoint:
        - /app/node_modules/.bin/aws-lambda-ric
      command:
        - apollo.lambda
    role: LambdaGraphQlRole

  migrate:
    handler: db/migrate.up
    role: LambdaGraphQlRole

  rollback:
    handler: db/migrate.back
    role: LambdaGraphQlRole

custom:
  webpack:
    webpackConfig: api/webpack.config.js
    includeModules:
      forceInclude:
        - pg
    packager: yarn
    keepOutputDirectory: true

@j0k3r
Copy link
Member

j0k3r commented Jun 10, 2021

Could you test again using the 5.5.1? Thanks 🙏

@j0k3r j0k3r added the awaiting reply Awaiting for a reply from the OP label Jun 10, 2021
@cnorthwood
Copy link
Author

Sadly not:

  Serverless Error ----------------------------------------
 
  No matching handler found for 'apollo' in '/builds/culture-shift/report-support'. Check your service definition.

@j0k3r j0k3r removed the awaiting reply Awaiting for a reply from the OP label Jun 10, 2021
@j0k3r
Copy link
Member

j0k3r commented Jun 10, 2021

From where the apollo coming from? I can't see a reference to it in the serverless.yml you shared.

@cnorthwood
Copy link
Author

in the definition of the server function, I would assume it's looking at the command of the lambda

@j0k3r
Copy link
Member

j0k3r commented Jun 10, 2021

Could you explain me what apollo.lambda is referencing to?

According to what was done here #723 and how it is supposed to work here, there should be a apollo.js file which export a lambda function. Isn't?

@cnorthwood
Copy link
Author

apollo.lambda is the command passed to the container image. The problem seems to be that it's incorrectly being interpreted as a JavaScript function, so it's looking for a function called lambda inside an apollo.js file - but that's not the case. It's just the command passed to the container. The problem appears to be serverless-webpack is trying to build it, but it's not a container image that Serverless is building itself (because the image has a uri field, it refers to an externally built image, not one built by Serverless). Ideally serverless-webpack shouldn't be trying to get involved in container images that the serverless framework isn't building

@j0k3r
Copy link
Member

j0k3r commented Jun 10, 2021

@cnorthwood could you check my attached PR? I've skipped off function when image.uri is defined.

@j0k3r j0k3r added this to the 5.5.2 milestone Jun 10, 2021
@cnorthwood
Copy link
Author

Unfortunately that doesn't seem to have changed anything

@j0k3r
Copy link
Member

j0k3r commented Jun 14, 2021

You still have the same error when using my PR?
I've tried locally using a simple function and it worked, with my PR I don't have the error anymore.

functions:
  server:
    image:
      uri: http://localhost
      command:
        - apollo.lambda

@cnorthwood
Copy link
Author

with apologies, it looks like I failed to change to the right branch - yes, that appears to be correct now

@j0k3r
Copy link
Member

j0k3r commented Jun 14, 2021

Good news!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants