Coder Social home page Coder Social logo

sirmmo / alpine-chrome Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zenika/alpine-chrome

0.0 1.0 0.0 60 KB

Chrome Headless docker images built upon alpine official image

Home Page: https://hub.docker.com/r/zenika/alpine-chrome

License: MIT License

Dockerfile 62.72% Shell 18.79% JavaScript 18.50%

alpine-chrome's Introduction

Docker Build Status Docker Pulls Layers Version

Supported tags and respective Dockerfile links

alpine-chrome

Chrome running in headless mode in a tiny Alpine image

Why this image

We often need a headless chrome. We created this image to get a fully headless chrome image. Be careful to the "--no-sandbox" flag from Chrome

3 ways to use Chrome Headless with this image

Not secured

Launch the container using:

docker container run -it --rm zenika/alpine-chrome and use the --no-sandbox flag for all your commands.

Be careful to know the website you're calling.

Explanation for the no-sandbox flag in a quick introduction here and for More in depth design document here

With SYS_ADMIN capability

Launch the container using: docker container run -it --rm --cap-add=SYS_ADMIN zenika/alpine-chrome

This allows to run Chrome with sandboxing but needs unnecessary privileges from a Docker point of view.

The best: With seccomp

Thanks to ever-awesome Jessie Frazelle seccomp profile for Chrome.

chrome.json

Also available here wget https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json

Launch the container using: docker container run -it --rm --security-opt seccomp=$(pwd)/chrome.json zenika/alpine-chrome

How to use in command line

Default entrypoint

The default entrypoint does the following command: chromium-browser --headless --disable-gpu

You can get full control by overriding the entrypoint using: docker run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser ...

Use the devtools

Command (with no-sandbox): docker container run -d -p 9222:9222 zenika/alpine-chrome --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/

Open your browser to: http://localhost:9222 and then click on the tab you want to inspect. Replace the beginning https://chrome-devtools-frontend.appspot.com/serve_file/@.../inspector.html?ws=localhost:9222/[END] by chrome-devtools://devtools/bundled/inspector.html?ws=localhost:9222/[END]

Print the DOM

Command (with no-sandbox): docker container run -it --rm zenika/alpine-chrome --no-sandbox --dump-dom https://www.chromestatus.com/

Print a PDF

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --print-to-pdf --hide-scrollbars https://www.chromestatus.com/

Take a screenshot

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars https://www.chromestatus.com/

Size of a standard letterhead.

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=1280,1696 https://www.chromestatus.com/

Nexus 5x

Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=412,732 https://www.chromestatus.com/

Screenshot owned by current user (by default the file is owned by the container user)

Command (with no-sandbox): docker container run -u `id -u $USER` -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=412,732 https://www.chromestatus.com/

How to use with Puppeteer

With tool like "Puppeteer", we can add a lot things with our Chrome Headless.

With some code in NodeJS, we can improve and make some tests.

See the "with-puppeteer" folder for more details.

If you have a NodeJS/Puppeteer script in your src folder named pdf.js, you can launch it using the following command:

docker run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node src/pdf.js

References

Versions (in latest)

Alpine version

docker run -it --rm --entrypoint "" zenika/alpine-chrome cat /etc/alpine-release
3.9.3

Chrome version

docker run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version
Chromium 73.0.3683.103

alpine-chrome's People

Contributors

brunobastosg avatar jlandure avatar jllado avatar ro31337 avatar sirmmo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.