Skip to content

Instantly share code, notes, and snippets.

@leaysgur
Last active April 6, 2017 02:56
Show Gist options
  • Save leaysgur/97e3aeb36795bfc0125fc1fa9d6ff90e to your computer and use it in GitHub Desktop.
Save leaysgur/97e3aeb36795bfc0125fc1fa9d6ff90e to your computer and use it in GitHub Desktop.
Docker image for node 6.x latest and yarn and karma w/ headless chrome
# yarn included
FROM node:6
# for installing chrome
RUN apt-get update -qqy \
&& apt-get -qqy install \
apt-transport-https \
ca-certificates \
ttf-wqy-zenhei \
ttf-unfonts-core \
wget
# install chrome
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -qqy \
&& apt-get -qqy install google-chrome-stable \
&& rm /etc/apt/sources.list.d/google-chrome.list \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
WORKDIR /workspace
// from https://github.com/karma-runner/karma/issues/2603
{
// ...
browsers: ['ChromeNoSandboxHeadless'],
customLaunchers: {
ChromeNoSandboxHeadless: {
base: 'Chrome',
flags: [
'--no-sandbox',
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'--headless',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
' --remote-debugging-port=9222',
],
},
},
// ...
}
@leaysgur
Copy link
Author

leaysgur commented Apr 3, 2017

めも1

いんたーねっと情報だと、Yarnは個別に入れるしかない風にみえる。
けど実際には、Nodeの公式イメージの中にあるやつにはだいたい最初から入ってる。

めも2

いんたーねっと情報だと、ヘッドレスなChromeを動かすにはXvfbが必要・・みたいな記事ばっか出てくる。
ただ、現世においてはもうstableでもヘッドレスモードで起動できるっぽいので、あれこれ楽できそう。

ただしいつのバージョンで入ったのかは不明でLinuxだから入ってるとかもあるかもしれないけどよく調べてない。

@leaysgur
Copy link
Author

leaysgur commented Apr 6, 2017

RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
 && sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
 && apt-get update -qq && apt-get install -qq \
  google-chrome-stable \
 && rm /etc/apt/sources.list.d/google-chrome.list \
 && rm -rf /var/lib/apt/lists/* /var/cache/apt/*

もはやこんだけでchrome入る疑惑

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment