Last active
August 25, 2017 20:56
-
-
Save MattSurabian/cc067cbf479b5bc6e41bab29cafda798 to your computer and use it in GitHub Desktop.
Dockerfile that builds an image running headless chrome and nodejs 8.4 in Ubuntu stable for sir calvin https://twitter.com/CWMma/status/901127364352114689
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# node-chrome-headless | |
# Builds an image capable of running nodejs 8.4 and headless Chrome in an Ubuntu container. | |
# Build with docker build . | |
# Based off: https://hub.docker.com/r/justinribeiro/chrome-headless/ | |
# Suggested run command: docker run -d -p 9222:9222 --cap-add=SYS_ADMIN | |
# | |
FROM ubuntu | |
LABEL name="node-chrome-headless" \ | |
maintainer="Matt Surabian <[email protected]>" \ | |
version="1.0" \ | |
description="Node and Google Chrome Headless in a container" | |
# Install deps + add NodeJS and Chrome Stable | |
RUN apt-get update && apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
build-essential \ | |
--no-install-recommends \ | |
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \ | |
&& apt-get install -y nodejs \ | |
&& 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 \ | |
# Add Chrome as a user | |
RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome \ | |
&& mkdir -p /home/chrome && chown -R chrome:chrome /home/chrome | |
# Run Chrome non-privileged | |
USER chrome | |
# Expose port 9222 | |
EXPOSE 9222 | |
# Autorun chrome headless with no GPU | |
ENTRYPOINT [ "google-chrome-stable" ] | |
CMD [ "--headless", "--disable-gpu", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment