commit 26543540c988290c8ffd87b10ab221924e893863 Author: Jeff Lindsay Date: Sat Jun 8 03:26:12 2013 -0700 initial commit diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 000000000..cf159919a --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,32 @@ +apt-get install -y linux-image-extra-`uname -r` +apt-get install -y software-properties-common +add-apt-repository -y ppa:dotcloud/lxc-docker +apt-get update +apt-get install -y lxc-docker +apt-get install -y git ruby nginx make + +cd /usr/local/bin +wget https://raw.github.com/progrium/gitreceive/master/gitreceive +chmod +x gitreceive +gitreceive init + +cd ~ +git clone https://github.com/progrium/buildstep.git +cd buildstep +cp buildstep /home/git/buildstep +make + + +cd ~ +git clone https://github.com/progrium/dokku.git +cd dokku +cp receiver /home/git/receiver +cp nginx-app-conf /home/git/nginx-app-conf +cp nginx-reloader.conf /etc/init/nginx-reloader.conf + +start nginx-reloader + +echo $HOSTNAME > /home/git/DOMAIN + +echo "Be sure to upload a public key for your user:" +echo " cat ~/.ssh/id_rsa.pub | ssh root@$HOStNAME \"gitreceive upload-key progrium\"" \ No newline at end of file diff --git a/nginx-app-conf b/nginx-app-conf new file mode 100755 index 000000000..1bd506daf --- /dev/null +++ b/nginx-app-conf @@ -0,0 +1,10 @@ +#!/bin/bash +APP="$1"; PORT="$2"; HOSTNAME="$3" +cat< Building $1 ..." +APP="app/$1" +cat | $HOME/buildstep $APP +echo "-----> Build complete!" +echo "-----> Deploying $1 ..." +if [[ -f "$HOME/DOMAIN" ]]; then + DOMAIN=$(< "$HOME/DOMAIN") +fi +if [[ -f "$HOME/$1/PORT" ]]; then + OLDID=$(< "$HOME/$1/CONTAINER") + docker kill $OLDID > /dev/null + PORT=$(< "$HOME/$1/PORT") + ID=$(docker run -d -p ":$PORT" -e "PORT=$PORT" $APP /bin/bash -c "cd /app && ./start") + echo $ID > "$HOME/$1/CONTAINER" +else + ID=$(docker run -d -p 5000 -e PORT=5000 $APP /bin/bash -c "cd /app && ./start") + echo $ID > "$HOME/$1/CONTAINER" + PORT=$(docker inspect $ID | ruby -e 'require"json";puts JSON.parse(STDIN.read)["NetworkSettings"]["PortMapping"]["5000"]') + echo $PORT > "$HOME/$1/PORT" + if [[ $DOMAIN ]]; then + $HOME/nginx-app-conf $1 $PORT $DOMAIN > $HOME/$1/nginx.conf + nc -U $HOME/reload-nginx + fi +fi +echo +echo "-----> Application deployed:" +if [[ $DOMAIN ]]; then + echo " http://$1.$DOMAIN" +else + echo " http://$(hostname -i | cut -d' ' -f3):$PORT" +fi +echo