Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Use chrome headless for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin Schnabel authored and ebullient committed Oct 27, 2020
1 parent 70dcbe2 commit 7e866e9
Show file tree
Hide file tree
Showing 9 changed files with 3,689 additions and 2,004 deletions.
45 changes: 22 additions & 23 deletions Dockerfile-node
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
FROM node:10
FROM alpine:edge
MAINTAINER Erin Schnabel <[email protected]> (@ebullientworks)

ARG userId=1000
ARG groupId=1000

ENV DEBIAN_FRONTEND noninteractive
ENV PHANTOMJS_VERSION 2.1.1
# Install chromium, node, vim, bash, ...
RUN apk add --no-cache \
bash curl chromium nss freetype freetype-dev harfbuzz ca-certificates ttf-freefont \
nodejs npm vim wget xvfb

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/xvfb-chromium
ENV CHROME_BIN=/usr/bin/xvfb-chromium
ENV HOME /app/node_modules/.home

RUN apt-get update \
&& apt-get install -y \
bzip2 \
curl \
&& apt-get autoremove \
&& apt-get clean \
&& npm -g install npm \
&& rm -rf /tmp/* /var/lib/apt/lists/*

RUN mkdir /tmp/phantomjs \
&& curl -L https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 \
| tar -xj --strip-components=1 -C /tmp/phantomjs \
&& cd /tmp/phantomjs \
&& mv bin/phantomjs /usr/local/bin \
&& echo 'export PATH=$PATH:/app/node_modules/.bin' >> /etc/bash.bashrc \
&& mkdir -p /app/node_modules \
&& chown -R ${userId}:${groupId} /app
COPY docker/docker-build.sh /usr/local/bin
COPY docker/xvfb-chromium /usr/bin/xvfb-chromium

RUN chmod +x /usr/local/bin/docker-build.sh /usr/bin/xvfb-chromium \
&& ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome \
&& echo 'export PATH=$PATH:/app/node_modules/.bin' >> /etc/bash.bashrc \
&& addgroup chrome \
&& adduser -H -D -s /bin/bash -u ${userId} -G chrome -h /app/node_modules/.home chrome \
&& addgroup chrome audio \
&& addgroup chrome video \
&& mkdir -p /app/node_modules \
&& chown -R ${userId}:${groupId} /app

WORKDIR /app

COPY docker/docker-build.sh /usr/local/bin
RUN chmod +x /usr/local/bin/docker-build.sh
USER ${userId}

#Express port
EXPOSE 3000
Expand Down
2 changes: 1 addition & 1 deletion app/gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ gulp.task('test', function(done) {
configFile: __dirname + '/karma.conf.js',
singleRun: true,
autoWatch: false,
browsers: ['PhantomJS']
browsers: ['ChromeHeadless']
}, done).start();
});

Expand Down
4 changes: 3 additions & 1 deletion app/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

// Karma configuration
// Generated on Fri Apr 21 2017 19:34:22 GMT-0400 (EDT)
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();

module.exports = function(config) {

Expand Down Expand Up @@ -99,7 +101,7 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [],
browsers: ['ChromeHeadless'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
Expand Down
Loading

0 comments on commit 7e866e9

Please sign in to comment.