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

Chrome flags required in an Amazon Lambda Docker image #914

Closed
gmetais opened this issue Mar 20, 2021 · 8 comments · Fixed by #917
Closed

Chrome flags required in an Amazon Lambda Docker image #914

gmetais opened this issue Mar 20, 2021 · 8 comments · Fixed by #917

Comments

@gmetais
Copy link
Contributor

gmetais commented Mar 20, 2021

I'm almost done making Phantomas run in an AWS Lambda Docker image. But I have an issue with Chrome not launching at all. I found a few answers thanks to this project: https://github.com/alixaxel/chrome-aws-lambda

It looks like Chrome requires to be started with the following additional flags: --no-sandbox --no-zygote --disable-gpu --single-process.

I think this use case won't be shared with many other Phantomas users and I don't want to complexify Phantomas with some hard to understand options such as --no-sandbox or --no-zygote. Any idea how we could do that? Would a single --aws-lambda-compatibility option be understandable/useful?

I still have the option to modify Phantomas' code inside my Docker image.

@macbre
Copy link
Owner

macbre commented Mar 22, 2021

Does AWS Lambda set any specific environment variable that we can detect and act accordingly (e.g. pass appropriate set of options to puppeteer when launching Chromium)?

@macbre
Copy link
Owner

macbre commented Mar 22, 2021

@gmetais - I assume you're trying to use "Container image" Lambda function?

https://docs.aws.amazon.com/lambda/latest/dg/configuration-images.html#configuration-images-settings - an env variable can be set then - PHANTOMAS_AS_LAMBDA?

@gmetais
Copy link
Contributor Author

gmetais commented Mar 22, 2021

Good idea!

Yes we can look at process.env.LAMBDA_TASK_ROOT. It is supposed to contain the directory name, so if the variable is a string, we can assume we're in a Lambda.

@gmetais
Copy link
Contributor Author

gmetais commented Mar 22, 2021

Otherwise yes, I can add a specific variable on my environment.

@macbre
Copy link
Owner

macbre commented Mar 22, 2021

process.env.LAMBDA_TASK_ROOT

Is this env variable set by the Amazon's Lambda stack for all lambdas? If so, let's use it - people can then use Phantomas server-lessly 😉 way easier - no need to set this yet another env variable that you need to remember about.

@gmetais , can you prepare a pull request then?

I'm wondering if we can automatically test phantomas in lambda somehow.

@macbre
Copy link
Owner

macbre commented Mar 22, 2021

@gmetais
Copy link
Contributor Author

gmetais commented Mar 22, 2021

I'm wondering if we can automatically test phantomas in lambda somehow.

It is possible, but it's kind of annoying. We first need to provide one of those:

  • a zip file that includes the entire project, including dependencies compiled for Lambda machines
  • a built docker image running on "Amazon Linux"

Then send it to AWS for deployment. And wait for deployment before testing.

@macbre
Copy link
Owner

macbre commented Mar 22, 2021

True, it's quite a complex procedure. Maybe as a nightly cron job? Let's consider it outside this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants