-
Notifications
You must be signed in to change notification settings - Fork 1
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
cache node_modules
to reduce build time
#858
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Datadog ReportBranch report: ✅ 0 Failed, 167 Passed, 34 Skipped, 47.17s Total Time |
note - to be merged after closing https://github.com/opengovsg/isomer-next-infra/pull/27 and pulumi up |
node_modules
and .next/cache
to reduce build time
5e5a855
to
6980cbc
Compare
node_modules
and .next/cache
to reduce build timenode_modules
to reduce build time
88e300e
to
fef636c
Compare
echo "Fetching cached node_modules..." | ||
NODE_MODULES_CACHE_PATH="s3://$S3_CACHE_BUCKET_NAME/$ISOMER_BUILD_REPO_BRANCH/isomer/node_modules.tar.gz" | ||
aws s3 cp $NODE_MODULES_CACHE_PATH node_modules.tar.gz || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: I think this will break our assumption that it takes at least 1 minute to reach the "fetching from database" step. Should we move that step further down after the "prebuilding" step and before the "building" step instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcshzj thanks for catching this!
But moving it between prebuilding and building wouldn't help too since prebuilding is cached just like node_modules
With this PR, if cache is found (which should be all builds except the first one after we publish a newer package version), then the time to reach "fetching from database" right after the 1) queuing of build + 2) provisioning of instances. A safe min. time needed from observing past build is 20s (provisioning of instances)
Problem
Reduce build time and cost by caching
partially closes https://linear.app/ogp/issue/ISOM-1661/optimise-site-build-times
Solution
Breaking Changes
Improvements:
TL;DR - cache
node_modules
and save ~2+ mins per buildapproach
how:
node_modules
(isomer)node_modules
(tooling/template)note
.next/cache
because it is too big and does not really speed upnext build
much. In fact, it's actually slower if we have to download the cache from S3 than actually building it on the spotISOMER_BUILD_REPO_BRANCH
which are fetch on build-time, which can't be done easily since we are using pulumi to define the stack