Created
May 2, 2014 16:19
-
-
Save bradleyg/6878575b176f34167fbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config | |
export HOME=/root | |
export SPINNERS=$HOME/spinners | |
# setup spinners | |
mkdir $SPINNERS | |
# deps | |
apt-get update -y | |
apt-get install -y docker.io git-core python-pip nginx golang byobu | |
# docker | |
ln -s /usr/bin/docker.io /usr/bin/docker | |
# fig | |
curl -L https://github.com/orchardup/fig/releases/download/0.4.0/linux > /usr/local/bin/fig | |
chmod +x /usr/local/bin/fig | |
# go | |
mkdir $SPINNERS/go | |
GOPATH=$SPINNERS/go | |
PATH=$GOPATH/bin:$PATH | |
echo "export GOPATH=$GOPATH" >> $HOME/.bashrc | |
echo "export PATH=$PATH" >> $HOME/.bashrc | |
source $HOME/.bashrc | |
# docker-gen | |
go get github.com/jwilder/docker-gen | |
# nginx template | |
mkdir $SPINNERS/templates | |
cat > $SPINNERS/templates/nginx.tmpl <<EOL | |
{{ range \$host, \$containers := groupBy \$ "Env.VIRTUAL_HOST" }} | |
upstream {{ \$host }} { | |
{{ range \$index, \$value := \$containers }} | |
{{ with \$address := index \$value.Addresses 0 }} | |
server {{ \$address.IP }}:{{ \$address.Port }}; | |
{{ end }} | |
{{ end }} | |
} | |
server { | |
#ssl_certificate /etc/nginx/certs/demo.pem; | |
#ssl_certificate_key /etc/nginx/certs/demo.key; | |
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
server_name {{ \$host }}; | |
location / { | |
proxy_pass http://{{ \$host }}; | |
include /etc/nginx/proxy_params; | |
} | |
} | |
{{ end }} | |
EOL | |
# upstart docker-gen | |
cat > "/etc/init/docker-gen.conf" <<EOL | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
exec $SPINNERS/go/bin/docker-gen -only-exposed -watch -notify "/etc/init.d/nginx reload" $SPINNERS/templates/nginx.tmpl /etc/nginx/sites-enabled/default | |
EOL | |
service docker-gen start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment