Slim version of Docker using Firefox. (#2914)
* Slim version of Docker using Firefox. At the moment this is not using xvfb, ffmpeg, imagemagick, python, visual metrics etc. #2913
This commit is contained in:
parent
91dd658f08
commit
a06ae1cb43
|
|
@ -18,9 +18,11 @@ matrix:
|
|||
addons:
|
||||
install:
|
||||
- docker build -t sitespeedio/sitespeed.io .
|
||||
- docker build -t sitespeedio/sitespeed.io:slim --file Dockerfile-slim .
|
||||
script:
|
||||
- docker run --rm sitespeedio/sitespeed.io https://www.sitespeed.io -n 1 -b chrome
|
||||
- docker run --rm sitespeedio/sitespeed.io https://www.sitespeed.io -n 1 -b firefox
|
||||
- docker run --rm sitespeedio/sitespeed.io:slim https://www.sitespeed.io -n 1
|
||||
- name: "Browser tests on Linux"
|
||||
sudo: required
|
||||
dist: bionic
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
FROM node:12.16.1-buster-slim
|
||||
|
||||
ENV SITESPEED_IO_BROWSERTIME__DOCKER true
|
||||
ENV SITESPEED_IO_BROWSERTIME__VIDEO false
|
||||
ENV SITESPEED_IO_BROWSERTIME__BROWSER firefox
|
||||
ENV SITESPEED_IO_BROWSERTIME__VISUAL_METRICS false
|
||||
ENV SITESPEED_IO_BROWSERTIME__HEADLESS true
|
||||
|
||||
ENV FIREFOX_VERSION 74.0
|
||||
|
||||
ENV PATH="/usr/local/bin:${PATH}"
|
||||
|
||||
RUN buildDeps='wget bzip2' && apt-get update && apt -y install $buildDeps && \
|
||||
# Download and unpack the correct Firefox version
|
||||
wget https://ftp.mozilla.org/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 && \
|
||||
tar -xjf firefox-${FIREFOX_VERSION}.tar.bz2 && \
|
||||
rm firefox-${FIREFOX_VERSION}.tar.bz2 && \
|
||||
mv firefox /opt/ && \
|
||||
ln -s /opt/firefox/firefox /usr/local/bin/firefox && \
|
||||
# Install dependencies for Firefox
|
||||
apt-get install -y --no-install-recommends --no-install-suggests \
|
||||
`apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` && \
|
||||
# iproute2 = tc
|
||||
apt -y install tcpdump iproute2 ca-certificates sudo --no-install-recommends --no-install-suggests && \
|
||||
# Cleanup
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $toolDeps \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/*
|
||||
|
||||
# Install sitespeed.io
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
COPY . /usr/src/app
|
||||
RUN CHROMEDRIVER_SKIP_DOWNLOAD=true EGDEDRIVER_SKIP_DOWNLOAD=true npm install --production
|
||||
WORKDIR /usr/src/app
|
||||
COPY docker/scripts/start-slim.sh /start.sh
|
||||
|
||||
# Allow all users to run commands needed by sitespeedio/throttle via sudo
|
||||
# See https://github.com/sitespeedio/throttle/blob/master/lib/tc.js
|
||||
RUN echo 'ALL ALL=NOPASSWD: /usr/sbin/tc, /usr/sbin/route, /usr/sbin/ip' > /etc/sudoers.d/tc
|
||||
|
||||
ENTRYPOINT ["bash","/start.sh"]
|
||||
VOLUME /sitespeed.io
|
||||
WORKDIR /sitespeed.io
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
firefox --version
|
||||
|
||||
SITESPEEDIO=/usr/src/app/bin/sitespeed.js
|
||||
|
||||
MAX_OLD_SPACE_SIZE="${MAX_OLD_SPACE_SIZE:-2048}"
|
||||
|
||||
WORKDIR_UID=$(stat -c "%u" .)
|
||||
WORKDIR_GID=$(stat -c "%g" .)
|
||||
|
||||
# Create user with the same UID and GID as the owner of the working directory, which will be used
|
||||
# to execute node. This is partly for security and partly so output files won't be owned by root.
|
||||
groupadd --non-unique --gid $WORKDIR_GID sitespeedio
|
||||
useradd --non-unique --uid $WORKDIR_UID --gid $WORKDIR_GID --home-dir /tmp sitespeedio
|
||||
|
||||
# Need to explictly override the HOME directory to prevent dconf errors like:
|
||||
# (firefox:2003): dconf-CRITICAL **: 00:31:23.379: unable to create directory '/root/.cache/dconf': Permission denied. dconf will not work properly.
|
||||
export HOME=/tmp
|
||||
|
||||
|
||||
# Inspired by docker-selenium way of shutting down
|
||||
function shutdown {
|
||||
kill -s SIGTERM ${PID}
|
||||
wait $PID
|
||||
}
|
||||
|
||||
chroot --skip-chdir --userspec='sitespeedio:sitespeedio' / node --max-old-space-size=$MAX_OLD_SPACE_SIZE $SITESPEEDIO "$@" &
|
||||
|
||||
PID=$!
|
||||
|
||||
trap shutdown SIGTERM SIGINT
|
||||
wait $PID
|
||||
|
||||
|
||||
|
|
@ -17,7 +17,10 @@ PACKAGE_VERSION=$(node -e 'console.log(require("./package").version)')
|
|||
|
||||
docker build --no-cache -t sitespeedio/sitespeed.io:$PACKAGE_VERSION -t sitespeedio/sitespeed.io:latest .
|
||||
docker push sitespeedio/sitespeed.io:$PACKAGE_VERSION
|
||||
# docker push sitespeedio/sitespeed.io:latest
|
||||
docker push sitespeedio/sitespeed.io:latest
|
||||
|
||||
docker build --no-cache -t sitespeedio/sitespeed.io:$PACKAGE_VERSION-slim --file Dockerfile-slim .
|
||||
docker push sitespeedio/sitespeed.io:$PACKAGE_VERSION-slim
|
||||
|
||||
docker build -t sitespeedio/sitespeed.io:$PACKAGE_VERSION-action --build-arg version=$PACKAGE_VERSION --file docker/github-action/Dockerfile .
|
||||
docker push sitespeedio/sitespeed.io:$PACKAGE_VERSION-action
|
||||
|
|
|
|||
Loading…
Reference in New Issue