-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: allow to use custom LLRT binary with llrtBinaryPath
#12
Conversation
…o find the "bootstrap" binary in
@georeeve hi thanks for the PR! to clarify, what is the usecase for this feature? (Why do you want to configure the cache directory?) Thanks. |
@tmokmss Hi, sorry if I didn't make it clear in the docs. My use case was that I wanted to test out a commit from LLRT's main branch, so I built the bootstrap binary locally. I then wanted to deploy this in my stack. I could have tricked LLRT CDK into deploying the binary by saving it as the So with this PR, you can set |
@georeeve Thanks for the detailed clarification! Actually I have some concerns about this proposed feature:
Instead, I'd just overwrite |
Those concerns are valid, I still think there's a use case for some projects to want to use a custom binary permanently in their project, perhaps if they apply some specific patches on top of LLRT. Would you accept a |
I see. then let's add the feature! I'll take a close look at the PR tomorrow so just a moment please 🙏 |
@tmokmss Sorry for the delay, I've added the |
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.
Thank you @georeeve! I'll confirm the detailed behavior in my local env tomorrow. I think we can merge this after that :)
src/llrt-function.ts
Outdated
@@ -130,7 +137,7 @@ export class LlrtFunction extends NodejsFunction { | |||
rm -rf llrt_temp.zip | |||
fi`, | |||
`cp ${posix.join(i, cacheDir, 'bootstrap')} ${o}`, | |||
], | |||
] : [`cp ${posix.join(i, props.llrtBinaryPath)} ${o}`], |
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.
Not sure if this works well in some edge cases. Does it work whenforceDockerBundling: true
and/or depsLockFilePath: 'some/child/packege-lock.json'
? I'll test those cases later.
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.
Also we may need an integration test to maintain this feature. I'll add one along the above test.
edit) @georeeve If you are willing to add it, that is totally welcome though!
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.
Good spot, I'm not sure if it would work with forceDockerBundling
. I imagine you would have to mount the directory somehow but I don't know if there's an option for that?
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.
@tmokmss I can take a look at the integration tests, does it just run with yarn integ-runner
?
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.
yes. you may need to run yarn build for tsc though.
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.
Confirmed that as long as llrtBinaryPath is relative to the projectRoot
directory, it works even with Docker. I added that information to jsdoc.
@@ -38,6 +38,13 @@ export interface LlrtFunctionProps extends NodejsFunctionProps { | |||
* @default LlrtBinaryType.STANDARD | |||
*/ | |||
readonly llrtBinaryType?: LlrtBinaryType; | |||
|
|||
/** | |||
* A custom relative path to use as a local LLRT bootstrap binary. |
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.
@georeeve have you tried to support absolute paths as well? Ideally we want to support them but I suspect it is difficult.
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.
I haven't, I can try but I'm not able to test the behaviour on Windows, which I imagine would be different. If Windows requires Docker builds then I suppose that's a different problem entirely though.
@georeeve I made some minor modification to the code and doc, as well as adding an integ-test. If you are okay with these changes, I'll merge this! :) |
@tmokmss LGTM, thanks for doing that. |
llrtBinaryPath
Adds a
llrtCustomBinaryDirectory
property to allow users to use their own LLRT bootstrap binary.This could be implemented in a few different ways. I tried to keep as much of the existing solution as possible:
If
llrtCustomBinaryDirectory
is set, it looks for a "bootstrap" binary in that directory, and errors if it cannot find one.If
llrtCustomBinaryDirectory
is not set, the binary is downloaded from GitHub and cached in the.tmp
directory as before.