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

NodeJs14.x Docker & AWS Image Support #1262

Closed
mikewolfd opened this issue Aug 19, 2021 · 4 comments
Closed

NodeJs14.x Docker & AWS Image Support #1262

mikewolfd opened this issue Aug 19, 2021 · 4 comments

Comments

@mikewolfd
Copy link

mikewolfd commented Aug 19, 2021

Feature Request

Due Amazon/AWS beginning to maintain/releasing their own docker node images, it looks like docker-lambda support might be dropping off. Localstack has a solution of merging the lambci and aws-lambda-nodejs images as an interim solution. Could we migrate to using AWS's docker images instead of lambci to support nodejs14.x support and future releases?

lambci/docker-lambda#329
lambci/docker-lambda#330
localstack/localstack#3688
lambci/node-custom-lambda#25

@wilson208
Copy link

wilson208 commented Aug 31, 2021

I would be very keen to see node 14.x supported in serverless-offline, and if there was appetite for it I would be happy to work on a PR to get it over the line.

@pgrzesik
Copy link
Collaborator

pgrzesik commented Sep 1, 2021

Hello @wilson208 👋 PR that attempts to switch to AWS official images would definitely be very welcome 🙌

@apancutt
Copy link
Contributor

apancutt commented Sep 11, 2021

We use Docker Compose to create a local development environment consisting of various applications that work with each other. Each of these apps are running in their own container. They're written in TypeScript and run on Node 14.

Since serverless-offline doesn't support Node 14 in Docker, trying to use our API service locally - particularly with our React frontend application - is painfully slow (~3s per request).

Trying to refactor serverless-offline to use AWS' Lambda images feels like a lost cause; it would drastically change the underlying architecture resulting in a lot of merge friction, would require tonnes of testing, and the PR/release process for this package is woefully slow... and I needed something quick.

I decided to port our API from serverless+serverless-offline to aws-sam-cli, but after all that effort I stumbled on this issue which killed that idea. Any frontend application demands an API that supports concurrent requests.

So after all that I decided to roll my own Serverless plugin to suit my needs. What it provides:

  • An API Gateway server compliant with HttpApi, V2 payloads and CORS
  • API Gateway proxies to a persistent container running official Lambda images
  • Support for Lambda env vars, timeout and runtime settings (currently only Node runtimes are supported)
  • Compatibility with serverless-webpack (uses the same lifecycle as serverless-offline) to watch+build TS to JS
  • Watches build output and automatically restarts container (~3 seconds)
  • Container connects to Docker Compose network for access to other containers

What it doesn't support (yet?):

  • Authorizer functions
  • Multiple functions (we use a single catch-all $default route)
  • Non-HttpApi events
  • V1 payloads

First request takes ~5 seconds, subsequent requests are a few ms.

I plan to use this at least until AWS SAM supports concurrent requests, or serverless-offline has better support for Docker.

Until then, if there is demand, I can make this package publicly available.

@wilson208
Copy link

wilson208 commented Sep 11, 2021

Have a WIP PR for this submitted, would appreciate any early feedback, needs a lot more testing etc but wanted to get some feedback on the approach before I get in too deep

#1274

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

No branches or pull requests

5 participants