fairly major refactoring. consolidating code into dokku script. also, went back to installing docker from ppa
This commit is contained in:
1 parent
0d49424c45
commit
1ee35cb3b9
4 files changed
+65
-41
No files matched your search
@@ -6,8 +6,6 @@ all: install
|
|||||||
install: gitreceive sshcommand
|
install: gitreceive sshcommand
|
||||||
cp dokku /usr/local/bin/dokku
|
cp dokku /usr/local/bin/dokku
|
||||||
cp receiver /home/git/receiver
|
cp receiver /home/git/receiver
|
||||||
cp deploystep /home/git/deploystep
|
|
||||||
cp buildstep /home/git/buildstep
|
|
||||||
cp nginx-app-conf /home/git/nginx-app-conf
|
cp nginx-app-conf /home/git/nginx-app-conf
|
||||||
cp nginx-reloader.conf /etc/init/nginx-reloader.conf
|
cp nginx-reloader.conf /etc/init/nginx-reloader.conf
|
||||||
echo "include /home/git/*/nginx.conf;" > /etc/nginx/conf.d/dokku.conf
|
echo "include /home/git/*/nginx.conf;" > /etc/nginx/conf.d/dokku.conf
|
||||||
@@ -23,4 +21,4 @@ sshcommand:
|
|||||||
sshcommand create dokku /usr/local/bin/dokku
|
sshcommand create dokku /usr/local/bin/dokku
|
||||||
|
|
||||||
count:
|
count:
|
||||||
cat receiver deploystep buildstep bootstrap.sh nginx-app-conf nginx-reloader.conf | wc -l
|
cat receiver dokku bootstrap.sh nginx-app-conf nginx-reloader.conf | wc -l
|
||||||
+9
-13
@@ -1,30 +1,26 @@
|
|||||||
DOKKU_REPO=${DOKKU_REPO:-"https://github.com/progrium/dokku.git"}
|
DOKKU_REPO=${DOKKU_REPO:-"https://github.com/progrium/dokku.git"}
|
||||||
DOKKU_STACK=${DOKKU_STACK:-"https://s3.amazonaws.com/progrium-dokku/progrium_buildstep.tgz"}
|
DOKKU_STACK=${DOKKU_STACK:-"https://s3.amazonaws.com/progrium-dokku/progrium_buildstep.tgz"}
|
||||||
DOCKER_PKG=${DOCKER_PKG:-"https://launchpad.net/~dotcloud/+archive/lxc-docker/+files/lxc-docker_0.4.2-1_amd64.deb"}
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
apt-get update
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y linux-image-extra-`uname -r`
|
DEBIAN_FRONTEND=noninteractive apt-get install -y linux-image-extra-`uname -r`
|
||||||
apt-get install -y git nginx make curl dnsutils
|
apt-get install -y python-software-properties
|
||||||
|
add-apt-repository -y ppa:dotcloud/lxc-docker
|
||||||
wget -qO- "$DOCKER_PKG" > /tmp/lxc-docker_0.4.2-1_amd64.deb
|
apt-get update && apt-get install -y lxc-docker git nginx make curl dnsutils
|
||||||
dpkg --force-depends -i /tmp/lxc-docker_0.4.2-1_amd64.deb && apt-get install -f -y
|
|
||||||
rm /tmp/lxc-docker_0.4.2-1_amd64.deb
|
|
||||||
|
|
||||||
sed -i.bak 's/docker -d/docker -d -r=true/' /etc/init/docker.conf # Docker should restart containers
|
|
||||||
|
|
||||||
cd ~ && git clone ${DOKKU_REPO}
|
cd ~ && git clone ${DOKKU_REPO}
|
||||||
cd dokku && make install
|
cd dokku && make install
|
||||||
|
|
||||||
curl "$DOKKU_STACK" | gunzip -cd | docker import - progrium/buildstep
|
curl "$DOKKU_STACK" | gunzip -cd | docker import - progrium/buildstep
|
||||||
|
|
||||||
[[ -f /etc/nginx/nginx.conf ]] && sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf
|
sed -i 's/docker -d/docker -d -r=true/' /etc/init/docker.conf
|
||||||
|
sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
[[ $(dig +short $HOSTNAME) ]] && hostfile="DOMAIN" || hostfile="HOSTNAME"
|
||||||
|
echo $HOSTNAME > /home/git/$hostfile
|
||||||
|
|
||||||
/etc/init.d/nginx start
|
/etc/init.d/nginx start
|
||||||
start nginx-reloader
|
start nginx-reloader
|
||||||
|
|
||||||
[[ $(dig +short $HOSTNAME) ]] && HOSTFILE=DOMAIN || HOSTFILE=HOSTNAME
|
|
||||||
echo $HOSTNAME > /home/git/$HOSTFILE
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Be sure to upload a public key for your user:"
|
echo "Be sure to upload a public key for your user:"
|
||||||
echo " cat ~/.ssh/id_rsa.pub | ssh root@$HOSTNAME \"gitreceive upload-key progrium\""
|
echo " cat ~/.ssh/id_rsa.pub | ssh root@$HOSTNAME \"gitreceive upload-key progrium\""
|
||||||
@@ -1,5 +1,58 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
case "$1" in
|
set -e; case "$1" in
|
||||||
|
receive)
|
||||||
|
APP="$2"; IMAGE="app/$APP"
|
||||||
|
echo "-----> Building $APP ..."
|
||||||
|
cat | dokku build $IMAGE
|
||||||
|
echo "=====> Build complete!"
|
||||||
|
echo "-----> Deploying $APP ..."
|
||||||
|
dokku deploy $APP $IMAGE
|
||||||
|
echo "=====> Application deployed:"
|
||||||
|
echo " http://$(< "$HOME/$APP/HOSTNAME")"
|
||||||
|
echo
|
||||||
|
;;
|
||||||
|
|
||||||
|
build)
|
||||||
|
IMAGE="$2"
|
||||||
|
# Place the app inside the container
|
||||||
|
id=$(cat | docker run -i -a stdin progrium/buildstep /bin/bash -c "mkdir -p /app && tar -xC /app")
|
||||||
|
test $(docker wait $id) -eq 0
|
||||||
|
docker commit $id $IMAGE > /dev/null
|
||||||
|
# Run the builder script and attach to view output
|
||||||
|
id=$(docker run -d $IMAGE /build/builder)
|
||||||
|
docker attach $id
|
||||||
|
test $(docker wait $id) -eq 0
|
||||||
|
docker commit $id $IMAGE > /dev/null
|
||||||
|
;;
|
||||||
|
|
||||||
|
deploy)
|
||||||
|
APP="$1"; IMAGE="$2"
|
||||||
|
if [[ ! -f "$HOME/$APP/PORT" ]]; then
|
||||||
|
# First deploy
|
||||||
|
id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web")
|
||||||
|
echo $id > "$HOME/$APP/CONTAINER"
|
||||||
|
port=$(docker port $id 5000)
|
||||||
|
echo $port > "$HOME/$APP/PORT"
|
||||||
|
if [[ -f "$HOME/DOMAIN" ]]; then
|
||||||
|
hostname="${APP/\//-}.$(< "$HOME/DOMAIN")"
|
||||||
|
$HOME/nginx-app-conf ${APP/\//-} $port $hostname > $HOME/$APP/nginx.conf
|
||||||
|
nc -U $HOME/reload-nginx
|
||||||
|
else
|
||||||
|
hostname="$(< "$HOME/HOSTNAME"):$port"
|
||||||
|
fi
|
||||||
|
echo $hostname > "$HOME/$APP/HOSTNAME"
|
||||||
|
else
|
||||||
|
# Regular deploy
|
||||||
|
oldid=$(< "$HOME/$APP/CONTAINER")
|
||||||
|
docker kill $oldid > /dev/null
|
||||||
|
port=$(< "$HOME/$APP/PORT")
|
||||||
|
id=$(docker run -d -p ":$port" -e "PORT=$port" $IMAGE /bin/bash -c "/start web")
|
||||||
|
echo $id > "$HOME/$APP/CONTAINER"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
logs)
|
logs)
|
||||||
CONTAINER=$(</home/git/$2/CONTAINER)
|
CONTAINER=$(</home/git/$2/CONTAINER)
|
||||||
docker logs $CONTAINER | tail -n 100
|
docker logs $CONTAINER | tail -n 100
|
||||||
@@ -9,15 +62,4 @@ case "$1" in
|
|||||||
echo "http://$(< "/home/git/$2/HOSTNAME")"
|
echo "http://$(< "/home/git/$2/HOSTNAME")"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
create-user)
|
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
delete-user)
|
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "Usage: ..."
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
@@ -1,14 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e; cat | dokku receive $1
|
||||||
APP="$1"
|
|
||||||
CONTAINER="app/$APP"
|
|
||||||
|
|
||||||
echo "-----> Building $APP ..."
|
|
||||||
cat | $HOME/buildstep $CONTAINER
|
|
||||||
echo "-----> Build complete!"
|
|
||||||
|
|
||||||
echo "-----> Deploying $APP ..."
|
|
||||||
$HOME/deploystep $APP $CONTAINER
|
|
||||||
echo "-----> Application deployed:"
|
|
||||||
echo " http://$(< "$HOME/$APP/HOSTNAME")"
|
|
||||||
echo
|
|
||||||
Reference in new issue
Block a user