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

Reduce package size with bundling #51

Closed
fromtheexchange opened this issue Jul 2, 2022 · 4 comments
Closed

Reduce package size with bundling #51

fromtheexchange opened this issue Jul 2, 2022 · 4 comments

Comments

@fromtheexchange
Copy link

On https://github.com/fromtheexchange/aws-lambda-ric, I bundled aws-lambda-ric with @vercel/ncc to reduce the package size from 128M to 688K. Bundling reduced my final image size by 25%.

@metaskills
Copy link

WOW, coming from the Ruby side where it is a simple gem install with no system dependencies needed, this feels like something worth doing.

Maybe at the least the README here should speak more to a docker multi-staage build/installation approach?

@jlarmstrongiv
Copy link

WOW, coming from the Ruby side where it is a simple gem install with no system dependencies needed

That’s the ideal solution, hopefully this PR will be merged #8 and all native dependencies can be removed.

Maybe at the least the README here should speak more to a docker multi-staage build/installation approach?

While multi-stage builds are possible, I find there are drawbacks too. I have to spend much more compute time building the image (especially if I’m using the ARM architecture), and frameworks like serverless still upload all stages to AWS’s ECR service, which can be upwards of 4 gigs with the multi-stage builds.

https://github.com/fromtheexchange/aws-lambda-ric

That’s an interesting approach, using GitHub Actions to publish containers you can copy from to avoid building from scratch every time. Unfortunately, there’s still the issue of #44 (comment), which means that the nodejs runtime interface client differs depending on whether you use docker containers or not (and prevents using ES Modules in the docker version).

Using the new AWS Linux 2022 is nice, but getting the right version of NodeJS installed is not straightforward nodesource/distributions#1367 (comment)

@metaskills anyway, watch out for those hidden gotcha’s. I ended up building my own system to manage NodeJS C++ addons too.

@metaskills
Copy link

hopefully this PR will be merged #8 and all native dependencies can be removed.

Yup, but given the age I might have to solution something as well.

That’s an interesting approach

Fun fact, I do the same here for this Rust-based Lambda Extension https://github.com/customink/crypteia#installation and I think I can do something similar for our Ubuntu images.

@krk
Copy link

krk commented Jun 23, 2023

This is fixed in #70.

@krk krk closed this as completed Jun 23, 2023
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

4 participants