From 01d57ef0dc5b2c14014a75e260aaffe530f19b2a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 25 Oct 2013 03:17:59 -0400 Subject: [PATCH] New command: dokku delete Two new hooks are implemented: - pre-delete $APP - post-delete $APP The following are implemented in the `post-delete` hook: - `$APP` directory deletion (00_dokku-standard) - nginx reload (nginx-vhosts) The following command can be executed by either the `dokku` or `git` user as `sudo`: sudo /etc/init.d/nginx reload Refs #124 Closes #186 --- AUTHORS | 2 ++ README.md | 13 ++----------- plugins/00_dokku-standard/commands | 22 ++++++++++++++++++++++ plugins/00_dokku-standard/install | 1 - plugins/00_dokku-standard/post-delete | 3 +++ plugins/nginx-vhosts/post-delete | 3 +++ 6 files changed, 32 insertions(+), 12 deletions(-) create mode 100755 plugins/00_dokku-standard/post-delete create mode 100755 plugins/nginx-vhosts/post-delete diff --git a/AUTHORS b/AUTHORS index 60b102704..94761debf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,8 +3,10 @@ # Alexander Alexander Beletsky +Alexis Gavoty Felipe Coury Jeff Lindsay +Jose Diaz-Gonzalez Leo Unbekandt Luigi Maselli Martin Weiss diff --git a/README.md b/README.md index 36b87c0d0..eab94b41a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index a644e514b..6d895f252 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -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=$( Delete an application logs Show the last logs for an application run Run a command in the environment of an application url Show the URL for an application diff --git a/plugins/00_dokku-standard/install b/plugins/00_dokku-standard/install index e83c28c0d..19eb91a76 100755 --- a/plugins/00_dokku-standard/install +++ b/plugins/00_dokku-standard/install @@ -17,4 +17,3 @@ script sudo -i -u git /usr/local/bin/dokku deploy:all end script EOF - diff --git a/plugins/00_dokku-standard/post-delete b/plugins/00_dokku-standard/post-delete new file mode 100755 index 000000000..58365c0c1 --- /dev/null +++ b/plugins/00_dokku-standard/post-delete @@ -0,0 +1,3 @@ +#!/bin/bash +set -e +[[ -n $1 ]] && rm -r "/home/git/$1" > /dev/null diff --git a/plugins/nginx-vhosts/post-delete b/plugins/nginx-vhosts/post-delete new file mode 100755 index 000000000..092bade06 --- /dev/null +++ b/plugins/nginx-vhosts/post-delete @@ -0,0 +1,3 @@ +#!/bin/bash +set -e +sudo /etc/init.d/nginx reload > /dev/null \ No newline at end of file