{"id":20989617,"url":"https://github.com/starkos/chromium-lambda-layer","last_synced_at":"2025-07-04T05:08:15.612Z","repository":{"id":193574271,"uuid":"689088921","full_name":"starkos/chromium-lambda-layer","owner":"starkos","description":"A Lambda layer with Chromium, the Chrome driver, and Java example code","archived":false,"fork":false,"pushed_at":"2023-09-08T19:51:20.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-28T02:02:05.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starkos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-08T19:16:39.000Z","updated_at":"2024-11-09T20:34:46.000Z","dependencies_parsed_at":"2023-09-08T20:53:41.746Z","dependency_job_id":null,"html_url":"https://github.com/starkos/chromium-lambda-layer","commit_stats":null,"previous_names":["starkos/chromium-lambda-layer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/starkos/chromium-lambda-layer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkos%2Fchromium-lambda-layer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkos%2Fchromium-lambda-layer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkos%2Fchromium-lambda-layer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkos%2Fchromium-lambda-layer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starkos","download_url":"https://codeload.github.com/starkos/chromium-lambda-layer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkos%2Fchromium-lambda-layer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263450011,"owners_count":23468153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T06:25:33.163Z","updated_at":"2025-07-04T05:08:15.584Z","avatar_url":"https://github.com/starkos.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chromium AWS Lambda Layer for Java\n\n## How I made this image\n\n1. Grab the latest `*-layer.zip` release from [@Sparticuz/chromium](https://github.com/Sparticuz/chromium). Unpack it, then find the compressed binaries at `nodejs/node_modules/@sparticuz/chromium/bin/`.\n\n2. Copy `chromium.br` to the layer's root folder. Decompress `aws.tar.br` and `swiftshader.tar.br` using [Brotli](https://github.com/google/brotli) and move the library files and `vk_swiftshader_icd` to the layer's `lib/` folder. _(I'm not shipping the compressed libraries because I couldn't figure out how to get Lambda to pick up `/tmp/lib` as a library search path; setting `LD_LIBRARY_PATH` in the Lambda environment didn't work for me. If you can figure out a way all of the binaries could be compressed to reduce the layer size quite a lot.)_\n\n3. Deploy a Linux64 [AWS Lambda container image](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html) to a Docker container. Copy out these files from `/usr/lib64` and place them in the layer's `lib/` folder: `libglib-2.0.so.0`, `libXau.so.6`, `libxcb.so.1`\n\n4. Grab the [Linux64 Chrome Web Driver](https://googlechromelabs.github.io/chrome-for-testing/) corresponding the version of Chromium downloaded above. Use Brotli to compress the `chromedriver` executable; copy `chromedriver.br` to the layer's root folder next to `chromium.br`.\n\n## Using the image\n\nSee [AwsChromium.java](./app/src/main/java/com/example/AwsChromium.java) for an example of how to decompress the executables and create a Selenium `ChromeDriver`.\n\n## Testing\n\nI used a Linux64 [AWS Lambda container image](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html) running locally in Docker to puzzle this stuff out; see the included [Dockerfile](./Dockerfile). To use it, place the contents of the layer in a folder called `layer/` at the same level as `Dockerfile`, then create a Docker image.\n\n```\n$ gradle build\n$ docker build --platform linux/amd64 -t chromium-lambda:test .\n```\n\nStart the container.\n\n```\n$ docker run -p 9000:8080 chromium-lambda:test\n```\n\nInvoke the method via Powershell or Curl.\n\n```\n$ Invoke-WebRequest -Uri \"http://localhost:9000/2015-03-31/functions/function/invocations\" -UseBasicParsing -Body \"{}\" -Method POST\n\n$ curl \"http://localhost:9000/2015-03-31/functions/function/invocations\" -d '{}'\n```\n\nOr open a terminal on the container and run `App.jar` directly.\n\n```\n$ java -jar App.jar\n```\n\nI found it helpful to decompress `chromium` and `chromedriver` and try executing them from the terminal to see which library dependencies were missing. Use `yum` to install the required libraries and then copy them out of `/usr/lib64` and add them to the layer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkos%2Fchromium-lambda-layer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarkos%2Fchromium-lambda-layer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkos%2Fchromium-lambda-layer/lists"}