feat: add new presets for contenairized and lambda environments #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two new presets:
containerized: for containers images (e.g. Docker)lambdaInstance: for AWS lamda-like environements (e.g. Vercel).The former is just a convenience alias, since chromium sandboxing must almost always be disabled with docker.
Maybe we could also default
--user-data-dir=/tmptoo with this preset.The latter might interest a lot of people (and might be worth being documented in a future iteration) and offers the flags required to launch chromium on AWS lambda-like environements, such as serverless services like Vercel.
The following link shows a proof of concept of using deno + astral + chrome + vercel:
https://vercel-deno-runtime.vercel.app/#lambda_chromium.ts
There is however a small subtility though.
These environement are resources tight so you need to use a trimmed down version of chromium (like
Sparticuz/chromium, which is a fork of the unmaintainedalixaxel/chrome-aws-lambda) that has been compiled specifically for it, in addition to add extra optimizations flags to make it faster.It means that you cannot use the astral downloader for it, so I created a small tool for it
jsr:@libs/toolbox/download-lambda-chromiumbut it might be nice to integrate it directly to@astralscope. The only thing is that it's a third-party maintaining the upstream recompiled version.The flags are mostly taken from:
https://github.com/Sparticuz/chromium/blob/dd57f035695c6773e17768176bda1910b1e39287/source/index.ts#L33-L89