Skip to content

Commit

Permalink
Chrome headless image
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed Nov 9, 2017
0 parents commit 1eb358a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
How to Contribute
=================

This project welcomes your contribution. There are several ways to help out:

* Create an [issue](https://github.com/femtopixel/docker-google-chrome-headless/issues/) on GitHub,
if you have found a bug or have an idea for a feature
* Write test cases for open bug issues
* Write patches for open bug/feature issues

There are a few guidelines that we need contributors to follow, so that we have a
chance of keeping on top of things.

Issues
------

* Submit an [issue](https://github.com/femtopixel/docker-google-chrome-headless/issues/)
* Make sure it does not already exist.
* Clearly describe the issue including steps to reproduce, when it is a bug.
* Make sure you note the version you use.

Additional Resources
--------------------

* [Existing issues](https://github.com/femtopixel/docker-google-chrome-headless/issues/)
* [General GitHub documentation](https://help.github.com/)
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM bitnami/minideb

MAINTAINER Jay MOULIN <[email protected]> <http://twitter.com/moulinjay>

ENV CHROME_DEBUG_PORT=9222

# Install deps + add Chrome Stable + purge all the things
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg --no-install-recommends && \
curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
apt-get update && apt-get install -y google-chrome-stable --no-install-recommends && \
apt-get purge --auto-remove -y curl gnupg && \
rm -rf /var/lib/apt/lists/* && \
groupadd -r chrome && useradd -r -g chrome -G audio,video chrome && \
mkdir -p /home/chrome/reports && chown -R chrome:chrome /home/chrome

COPY entrypoint.sh /usr/bin/entrypoint

# Run Chrome non-privileged
USER chrome

# Drop to cli
ENTRYPOINT ["entrypoint"]
8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2017 FemtoPixel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Google Chrome Headless - Docker Image
================================

[![latest release](https://img.shields.io/github/release/femtopixel/docker-google-chrome-headless.svg "latest release")](http://github.com/femtopixel/docker-google-chrome-headless/releases)
[![Docker Pulls](https://img.shields.io/docker/pulls/femtopixel/google-chrome-headless.svg)](https://hub.docker.com/r/femtopixel/google-chrome-headless/)
[![Docker Stars](https://img.shields.io/docker/stars/femtopixel/google-chrome-headless.svg)](https://hub.docker.com/r/femtopixel/google-chrome-headless/)
[![Bitcoin donation](https://github.com/jaymoulin/jaymoulin.github.io/raw/master/btc.png "Bitcoin donation")](https://m.freewallet.org/id/374ad82e/btc)
[![Litecoin donation](https://github.com/jaymoulin/jaymoulin.github.io/raw/master/ltc.png "Litecoin donation")](https://m.freewallet.org/id/374ad82e/ltc)

[Google Chrome Headless](https://developers.google.com/web/updates/2017/04/headless-chrome) is the Google Chrome borwser that can be started without graphical interface to accomplish several tasks (PDF printing, performance, automation...)

Usage
-----

```
docker run --rm --name chrome -it -p 9222:9222 --cap-add SYS_ADMIN femtopixel/google-chrome-headless <optional_args> <optional_site_url>
```

With `<optional_site_url>` url to your site (e.g. http://www.google.com). By default `about:blank`. You can pass args **BEFORE** the `url` if you want to use some.

By default, Chrome Headless listen on the `9222` port but this can be changed by passing the `CHROME_DEBUG_PORT` environment to the value you want.

### Example

```
docker run --rm --name chrome -it -p 9000:9000 -e CHROME_DEBUG_PORT=9000 femtopixel/google-chrome-headless <optional_args> <optional_site_url>
```

Usage : Improved
----------------

Using the ever-awesome [Jessie Frazelle](https://twitter.com/jessfraz) SECCOMP profile for Chrome, we don't have to use the hammer that is SYS_ADMIN:

```
wget https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json -O ~/chrome.json
docker run --rm --name chrome -it -p 9222:9222 --security-opt seccomp=$HOME/chrome.json femtopixel/google-chrome-headless <optional_args> <optional_site_url>
```
9 changes: 9 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

# first arg is `http` or `--some-option`
if [[ "http*" == "$1" ]] || [[ "-*" == "$1" ]] || [[ "about:blank" == "$1" ]] || [[ "$#" == 0 ]]; then
set -- google-chrome --headless --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=$CHROME_DEBUG_PORT "$@"
fi
exec "$@"

0 comments on commit 1eb358a

Please sign in to comment.