Skip to content

Instantly share code, notes, and snippets.

@mdobson
Last active December 29, 2015 15:49
Show Gist options
  • Select an option

  • Save mdobson/7692996 to your computer and use it in GitHub Desktop.

Select an option

Save mdobson/7692996 to your computer and use it in GitHub Desktop.
Deploy script
#!/bin/bash
if [ $(git rev-parse --is-bare-repository) = true ]
then
appName=$(basename "$PWD")
else
appName=$(basename $(readlink -nf "$PWD"/..))
fi
echo "Preparing to deploy $appName"
tarPath="$HOME/tmp/$appName.tar"
ipaddr=$(ip addr show eth0 | grep inet | head -n1 | awk '{ print $2 }')
endpoint=${ipaddr/\/[0-9][0-9]/}
containerId=$(docker -H $endpoint:4243 ps | grep $appName | awk '{ print $1 }')
echo "killing container $containerId"
docker -H $endpoint:4243 kill "$containerId"
docker -H $endpoint:4243 rm "$containerId"
git archive master -o $tarPath
cat $tarPath | buildstep $appName
currentContainer=$(docker -H $endpoint:4243 run -p 5000 -e PORT=5000 -d $appName /bin/bash -c "/start web")
echo "Recording deployment of $appName with id of $currentContainer"
sleep 5
record --host http://localhost:49159/deploys --dockerhost "http://$endpoint" --dockerport 4243 --app "$appName" --container "$currentContainer"
rm $tarPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment