Rayrun
← Back to Discord Forum

playwright docker image for AWS lambda in python?

I've been trying to build a docker image containing playwright to use as an AWS lambda function with python. Has anyone else been able to do this?

This thread is trying to answer question "Has anyone been able to build a docker image containing playwright to use as an AWS lambda function with Python?"

7 replies

Hi, those people might be hard to find, since running in AWS Lambda is uncommon and then combining that with Python makes it even less common. So despite not having experience with this, I thought I'd try to be helpful (maybe just being the 'rubber duck').

What issues are you running into?

And have you had a look at these articles? Especially on stackoverflow there seems to be some information on similar efforts by other people: https://www.google.com/search?q=playwright+aws+lambda+python

And there seems to be a Japanese article from someone who has succeeded at it. Linking to the Google translation of it: https://tech-smartshopping-co-jp.translate.goog/lambda-container-playwright?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp

Hi! I've been through that, only node.js, not Python but I managed to run Playwright inside docker in AWS Lambda and it's running on production already for couple of weeks 🙂 It did require a bit of research as it's not officially supported but it's there. AMA - I might be able to help if I ran into the same issues as you're having with Python.

BTW I'm using a custom docker image based on Ubuntu, couldn't make it work on images provided by AWS so I went the other way. I made my Ubuntu image compatible with AWS Lambda which is quite easy and all documented on AWS.

Oh... and I forgot one important thing. I did all this on arm architecture. With x86 that would have been so much easier 🙂

@irek_p: Hi Irek, awesome work! I’m wondering is your use case be web-scraping? If so where did you feed your aws lamda results to?

Hi Irek, awesome work! I’m wondering is your use case be web-scraping? If so where did you feed your aws lamda results to?

No, it's not web scraping that we do. It's much easier than scraping so we didn't have problems with feeding the results. It's a simple HTTP call to a webhook in another system but in our case the output is very small (<1KB).

patrickdoering
patrickdoering

@irek_p is the chrome browser running with the flag --single-process or "normal"

@patrickdoering: I had to use `--single-process` to run inside Lambda. Otherwise I was getting some weird errors which I can't remember now but it was something with DBus which is a Linux IPC which Chrome probably uses to communicate between child processes. For some reason it wasn't working properly even though my base image was a regular Ubuntu which should support that. I couldn't find any workaround for that though so ended up with this single process flag. However I don't see any downsides. It's already running for more than half year (e2e tests every day) and so far so good.

I had to use --single-process to run inside Lambda. Otherwise I was getting some weird errors which I can't remember now but it was something with DBus which is a Linux IPC which Chrome probably uses to communicate between child processes. For some reason it wasn't working properly even though my base image was a regular Ubuntu which should support that. I couldn't find any workaround for that though so ended up with this single process flag. However I don't see any downsides. It's already running for more than half year (e2e tests every day) and so far so good.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.