:point_up_2: Slightly related to the question abov...
# seed
a
👆 Slightly related to the question above, but does anyone have any tips or tricks to speed up our SST builds? Here's a screenshot of our build timings on a branch that's not the first run (i.e. caches should be hot I guess): Our seed.yml:
Copy code
before_compile:
  - n auto
  # This ensures that post-install hooks are run in CI in Ubuntu
  # <https://github.com/npm/npm/issues/3497>
  - npm install --unsafe-perm
As context, we're seeing about ~45 seconds of install time in github actions.
f
Can you DM the link to this build? Let me take a look what took long?
a
DM-d!
Any way to override the
npm install
command that seed does by default? I can't seem to find it here: https://seed.run/docs/adding-a-build-spec.html
or would a
mv package.json package.json.tmp
and a
mv package.json.tmp package.json
solve that? 😄
f
Are you looking to add options to
npm install
?
a
Not really, just do npm ci with a hot cache.
f
I see. Often
npm ci
end up being much slower than
npm install
.
npm ci
wipes out the
node_modules
and does a fresh install. It does use the
.npm
cache. With
.npm
cache, npm does’t have to re-download the modules, but it still need to build the dependency tree and etc, which is where most time is spent.
a
Ok, thanks for the info!
t
https://serverless-stack.slack.com/archives/C01UJ8MDHEH/p1624385290164000?thread_ts=1624371219.154700&amp;cid=C01UJ8MDHEH Hello @Frank 👋 Quick question. My packages installation takes ages to complete, I'm wondering if by default Seed also installs the dev dependencies? If yes, is there a way to specify option to
npm install
? like
--production
For example: My stack is deployed in
4m10s
but it took
154.75s
to run
npm install
More than 50% of the build time has been spent on the package installation 😢
f
Hey @Thibault! Normally the node modules should be cached between build. And
npm install
only gets run if
package.json
or
package-lock.json
is changed; or on
force deploy
.
If you DM me a link to ur build, I can get the team take a look why cache wasn’t being used.
t
The cache works fine no issue with that, it's only if my build failed before then the cache is skipped as expected but it's super long to reinstall all the dependencies.
I'm wondering if by default the
npm install
executed also installs the devDependencies?
For example I have the `serverless`package listed in
devDependencies
and I don't really need it for the deployment
On my devbox (which is not super performant)
Copy code
→ npm i
added 2989 packages, and audited 2990 packages in 4m
→ npm i --production
added 560 packages, and audited 561 packages in 51s
f
Can you try setting
NODE_ENV
to
production
? That should skip the devDependencies.
I’m thinking you can either set it as an secret on SEED, or set it in the
seed.yml
buildspec.
t
hmm good idea
thanks!
@Frank as a feedback, setting
NODE_ENV
to
production
is not a good option cause I use
serverless-seed
and it's defined in the
devDependencies
so I have to install them. But a good alternative is to use the
before_compile
hook and do
Copy code
echo progress=false >> ~/.npmrc
It disables the progress bar and reduce drastically the installation time 🎉
Copy code
INFO: before_compile hook not found. You can define it in your build spec.
INFO: Learn more about adding a build spec - seed.run/docs/adding-a-build-spec
INFO: Looking for package.json...
$ npm install
added 2726 packages, and audited 2727 packages in 3m
Copy code
INFO: Running before_compile hook
$ echo progress=false >> ~/.npmrc
INFO: Looking for package.json...
$ npm install
added 2726 packages, and audited 2727 packages in 49s
This simple option is a cost killer, it saved 50min of build time on my entire pipeline 😲 (edit: when the cache is skipped otherwise the cache does a great job)
f
WHAT! 🤯 Does this just disable npm from printing out the progress?
t
f
Got it! Man need to share this with other Seed folks.