Skip to content

Instantly share code, notes, and snippets.

@ysugimoto ysugimoto/setup.sh
Last active Mar 25, 2017

Embed
What would you like to do?
set up docker-compose.yml
#!/bin/bash
YOU=`whoami`
CWD=$(cd $(dirname $0);pwd)
# Create mout storage directory if not exists
if [ ! -d "$HOME/perfstore/graphite" ]; then
echo "creating directory: $HOME/perfstore/graphite..."
mkdir -p $HOME/perfstore/graphite
fi
if [ ! -d "$HOME/perfstore/grafana" ]; then
echo "creating directory: $HOME/perfstore/grafana..."
mkdir -p $HOME/perfstore/grafana
fi
if [ ! -d "$HOME/perfstore/sitespeed.io" ]; then
echo "creating directory: $HOME/perfstore/sitespeed.io..."
mkdir -p $HOME/perfstore/sitespeed.io
fi
if [ ! -d "$CWD/composer" ]; then
echo "creating directory: $CWD/composer..."
mkdir -p $CWD/composer
fi
# Generate docker-composer.yml on your env
cat << EOS > ${CWD}/composer/docker-compose.yml
graphite:
image: sitespeedio/graphite
name: graphite
ports:
- "8080:80"
- "2003:2003"
restart: always
volumes:
- /home/${YOU}/perfstore/graphite:/opt/graphite/storage/whisper
grafana:
image: grafana/grafana
name: grafana
restart: always
links:
- graphite
ports:
- "3000:3000"
volumes:
- /home/${YOU}/perfstore/grafana:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
sitespeedio:
image: sitespeedio/sitespeed.io
privileged: true
links:
- graphite
volumes:
- /home/${YOU}/perfstore/sitespeed.io:/sitespeed.io
sitespeedio-chrome:
image: sitespeedio/sitespeed.io-chrome
privileged: true
links:
- graphite
volumes:
- /home/${YOU}/perfstore/sitespeed.io:/sitespeed.io
EOS
echo "${CWD}/composer/docker-compose.yml file generated!"
echo "To run the docker containers:"
echo "cd ${CWD}/composer"
echo "docker-compose up -d"
exit $?
#!/bin/bash
YOU=`whoami`
HELP=
BROWSER="firefox"
IMAGE="sitespeed.io"
while getopts d: OPT; do
case $OPT in
d) BROWSER=$OPTARG
;;
esac
done
usage_exit() {
echo "Measurement URL must be supplied!"
echo "Usage: "
echo " ./sitespeedio.sh [-b browser] [URL]"
exit 1
}
if [ "$1" = "" ];then
usage_exit
fi
if [ ! "$BROWSER" = "chrome" -a ! "$BROWSER" = "firefox" ]; then
echo "[ERROR] Invalid target browser."
usage_exit
fi
if [ "$BROWSER" = "chrome" ]; then
IMAGE="sitespeed.io-chrome"
fi
echo "==================================================="
echo "sitespeed.io performance tracking"
echo "==================================================="
docker run \
--privileged \
--rm \
--link composer_graphite_1:graphite \
-v /home/${YOU}/perfstore/sitespeed.io:/sitespeed.io \
sitespeedio/${IMAGE} \
${IMAGE} \
-u $1 \
-b ${BROWSER} \
-n 5 \
-d 0 \
-r /tmp \
--graphiteHost graphite \
--graphiteNamespace sitespeed \
--graphiteDate summary,rules,pagemetrics,timings \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.