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

Shrinkwrapping with jest takes 30 more seconds due to node_modules #889

Open
1 of 2 tasks
tatemz opened this issue May 20, 2021 · 6 comments
Open
1 of 2 tasks

Shrinkwrapping with jest takes 30 more seconds due to node_modules #889

tatemz opened this issue May 20, 2021 · 6 comments

Comments

@tatemz
Copy link

tatemz commented May 20, 2021

Expected Behaviour

Shrinkwrapping a node project should not take long and should not copy node_modules into build directory because they are ignored by .dockerignore and installed during the build

Current Behaviour

Shrinkwrapping can take up to 30 seconds on a project where most of the function handler's dependencies are devDependencies (e.g. jest)

Are you a GitHub Sponsor (Yes/No?)

Check at: https://github.com/sponsors/openfaas

  • Yes
  • No

List All Possible Solutions and Workarounds

  • Add scripting to save and remove (stash) files/folders that you don't want copied before shrinkwrapping
  • Add scripting to re-add removed files after shrinkwrapping

Which Solution Do You Recommend?

I've proposed #888, but maybe there is a way to prefer using .dockerignore files when shrinkwrapping.

Steps to Reproduce (for bugs)

  1. Make a new handler using a node template
  2. npm i jest --save-dev to that handler
  3. faas-cli build --shrinkwrap
  4. Add more node_modules to see the copy process take longer

Context

Build time of 60+ seconds for simple projects

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):

  • Docker version ( Full output from: docker version ):

  • Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?

  • Operating System and version (e.g. Linux, Windows, MacOS):

  • Link to your project or a code example to reproduce issue:

@tatemz
Copy link
Author

tatemz commented Jul 27, 2021

Hello! I'm just checking back in. I filed this issue as it was a real problem when developing locally. My CI pipelines have no issue since node_modules are in the .gitignore of my projects. I made MR #888 and have been using that build locally for all of my tooling. Would love to know what the next steps are to getting this issue shared with the broader community 😄

Thanks for a great tool! It's off to a great start!

@alexellis
Copy link
Member

/msg: enduser

@derek
Copy link

derek bot commented Jul 28, 2021

Thank you for your interest in OpenFaaS. This project is maintained and made available for hobbyists and commercial users alike, so we need to balance our time across everyone's needs. Whilst we are excited in your interest in using OpenFaaS, we would also ask you to take a look at our contribution guide on Setting expectations, support and SLAs.

Commercial users can purchase support in order to get dedicated help from OpenFaaS Ltd, or they can book ad-hoc consulting hours to get an engineer to dedicate time to helping them.

If that is not a good fit for you at this time, please check out the OpenFaaS GitHub Sponsors options which are priced for practitioners like yourself. Organisations can also sponsor through their GitHub billing relationship.

When you become a sponsor as an indvidual, it will show this on your issues and PRs, so that the community can see that you are supporting our work, and can prioritise your needs.

If you are receiving this message after having received hands-on support from the OpenFaaS community, please join GitHub Sponsors to say thank you for our time.

Thank you for supporting OpenFaaS.

@alexellis
Copy link
Member

Please see comment: #888 (comment)

@alexellis
Copy link
Member

Just tried this on the Weekly Office Hours call and cannot reproduce the problem.

alex@alex-nuc8:/tmp/test$ faas-cli new --lang node17 lotsofstuff

alex@alex-nuc8:/tmp/test$ cd lotsofstuff/
alex@alex-nuc8:/tmp/test/lotsofstuff$ ls
handler.js  package.json
alex@alex-nuc8:/tmp/test/lotsofstuff$ npm i jest --save-dev

added 332 packages, and audited 333 packages in 11s

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


alex@alex-nuc8:/tmp/test$ time faas-cli build --shrinkwrap -f lotsofstuff.yml
[0] > Building lotsofstuff.
Clearing temporary build folder: ./build/lotsofstuff/
Preparing: ./lotsofstuff/ build/lotsofstuff/function
Building: lotsofstuff:latest with node17 template. Please wait..
lotsofstuff shrink-wrapped to ./build/lotsofstuff/
[0] < Building lotsofstuff done in 0.26s.
[0] Worker done.

Total build time: 0.26s

real	0m0.274s
user	0m0.065s
sys	0m0.221s
alex@alex-nuc8:/tmp/test$ ls
build  lotsofstuff  lotsofstuff.yml  template
alex@alex-nuc8:/tmp/test$ 


@alexellis
Copy link
Member

@tatemz can you provide an example to reproduce this?

Thanks,

Alex

@alexellis alexellis changed the title Shrinkwrapping takes 30 more seconds due to node_modules Shrinkwrapping with jest takes 30 more seconds due to node_modules Oct 5, 2022
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

2 participants