Merge pull request #262 from josegonzalez/app-deletion

App deletion
This commit is contained in:
rhy-jot
2013-10-27 15:29:46 -07:00
8 changed files with 41 additions and 26 deletions

View File

@@ -3,8 +3,10 @@
#
Alexander <iam.asm89@gmail.com>
Alexander Beletsky <alexander.beletsky@gmail.com>
Alexis Gavoty <kload@kload.fr>
Felipe Coury <felipe.coury@gmail.com>
Jeff Lindsay <progrium@gmail.com>
Jose Diaz-Gonzalez <dokku@josediazgonzalez.com>
Leo Unbekandt <leo@unbekandt.eu>
Luigi Maselli <grigio.org@gmail.com>
Martin Weiss <kornnflake@gmail.com>

View File

@@ -67,18 +67,9 @@ https://github.com/progrium/dokku/wiki/Plugins
## Removing a deployed app
Currently this is a manual process.
SSH onto the server, then execute:
To remove an app, ssh to the server, then run:
$ sudo docker ps
# Then from the list, take repository name of your app and run:
$ sudo docker stop app/node-js-sample
# To find the ids of images to delete, run:
$ sudo docker images
# Then from that list, take the IDs corresponding to your app, and
# those corresponding to no tag at all, and for each run:
$ sudo docker rmi 123456789
$ dokku delete myapp
## Environment setup

View File

@@ -1,5 +1,26 @@
#!/bin/bash
set -e; case "$1" in
delete)
if [[ -z $2 ]]; then
echo "Please specify an app to delete"
exit 1
fi
APP="$2"; IMAGE="app/$APP";
if [[ ! -d "/home/git/$APP" ]]; then
echo "App does not exist"
exit 1
fi
pluginhook pre-delete $APP
ID=$(< "/home/git/$APP/CONTAINER")
docker stop $ID > /dev/null
docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null &
docker rm $ID > /dev/null
pluginhook post-delete $APP
;;
logs)
CONTAINER=$(</home/git/$2/CONTAINER)
docker logs $CONTAINER | tail -n 100
@@ -33,6 +54,7 @@ set -e; case "$1" in
help)
cat && cat<<EOF
delete <app> Delete an application
logs <app> Show the last logs for an application
run <app> <cmd> Run a command in the environment of an application
url <app> Show the URL for an application

View File

@@ -17,4 +17,3 @@ script
sudo -i -u git /usr/local/bin/dokku deploy:all
end script
EOF

View File

@@ -0,0 +1,3 @@
#!/bin/bash
set -e
[[ -n $1 ]] && rm -r "/home/git/$1" > /dev/null

View File

@@ -5,18 +5,14 @@ add-apt-repository -y ppa:nginx/stable
apt-get update
apt-get install -y nginx dnsutils
cat<<EOF > /etc/init/nginx-reloader.conf
description "Dokku nginx reloader service"
start on runlevel [2345]
stop on runlevel [!2345]
script
[[ -f /home/git/reload-nginx ]] && rm -rf /home/git/reload-nginx
echo | sudo -u git nc -l -U /home/git/reload-nginx && /etc/init.d/nginx reload
end script
respawn
EOF
if ! grep -q dokku-nginx-reload "/etc/sudoers"; then
touch /etc/sudoers.tmp
cp /etc/sudoers /tmp/sudoers.new
echo "%dokku ALL=(ALL)NOPASSWD:/etc/init.d/nginx reload # dokku-nginx-reload" >> /tmp/sudoers.new
echo "%git ALL=(ALL)NOPASSWD:/etc/init.d/nginx reload # dokku-nginx-reload" >> /tmp/sudoers.new
EDITOR="cp /tmp/sudoers.new" visudo
rm /tmp/sudoers.new
fi
echo "include /home/git/*/nginx.conf;" > /etc/nginx/conf.d/dokku.conf
@@ -25,4 +21,3 @@ sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/n
[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME > /home/git/VHOST
/etc/init.d/nginx start
start nginx-reloader || true

View File

@@ -0,0 +1,3 @@
#!/bin/bash
set -e
sudo /etc/init.d/nginx reload > /dev/null

View File

@@ -79,5 +79,5 @@ EOF
echo "http://$hostname" > "$HOME/$APP/URL"
fi
pluginhook nginx-pre-reload $APP
nc -U $HOME/reload-nginx
sudo /etc/init.d/nginx reload
fi