Mise en place de Sitespeed.io pour runs quotidiens sur multi-sites

WORK IN PROGRESS

Ma version du script run.sh fourni dans la doc de sitespeed.io

L'idée ici était surtout de ne pas avoir a downloader l'image docker sytématiquement (1.7Go !), donc je l'ai "pull"ée une première fois, puis j'ai fait un docker save comme dans le script à la fin des runs...

#!/bin/bash
 
echo $$ > /var/run/ssio.pid
 
# Specify the exact version of sitespeed.io. When you upgrade to the next version, pull it down and the chage the tag
BASE_DIR=/var/www/sitespeed.io
SSIO_VER=6.5.4
DOCKER_CONTAINER=sitespeedio/sitespeed.io:$SSIO_VER
 
# Setup the network and default ones we wanna use
$BASE_DIR/start-networks.sh
THREEG="--network 3g"
CABLE="--network cable"
 
# Simplify some configurations
CONFIG="--config /sitespeed.io/config.json"
DOCKER_SETUP="--shm-size=1g --rm -v $BASE_DIR:/sitespeed.io -v /etc/localtime:/etc/localtime:ro --name sitespeed"
 
EXISTS=$(docker images |grep "sitespeed.io" | grep "$SSIO_VER" | wc -l)
if [ $EXISTS -eq 0 ] && [ -f $BASE_DIR/images/sitespeed.io-$SSIO_VER.tar ] ; then
   echo "loading docker image from $BASE_DIR/images/sitespeed.io-$SSIO_VER.tar..."
   docker load -i $BASE_DIR/images/sitespeed.io-$SSIO_VER.tar
elif [ $EXISTS -eq 0 ] ; then
  echo "no current image onboard, pulling it from docker..."
  # Get the container so we have it the next time we wanna use it
  docker pull $DOCKER_CONTAINER
fi
 
# Start running the tests
# We run more tests on our test server but this gives you an idea of how you can configure it
docker run $CABLE $DOCKER_SETUP $DOCKER_CONTAINER -n 3 /sitespeed.io/urls.txt $CONFIG
docker run $THREEG $DOCKER_SETUP $DOCKER_CONTAINER -n 3 --graphite.namespace sitespeed_io.emulatedMobile /sitespeed.io/urls.txt -c 3g --mobile true $CONFIG
docker run $CABLE $DOCKER_SETUP $DOCKER_CONTAINER -n 1 /sitespeed.io/others-urls.txt
 
if ! [ -f $BASE_DIR/images/sitespeed.io-$SSIO_VER.tar ] ; then
  echo "saving pulled image to $BASE_DIR/images/sitespeed.io-$SSIO_VER.tar"
  docker save $DOCKER_CONTAINER > $BASE_DIR/images/sitespeed.io-$SSIO_VER.tar
fi
 
echo "cleaning docker stuff..."
# We remove all docker stuff to get a clean next run
docker system prune --all --volumes -f
 
rm /var/run/ssio.pid