From f54ea2df28f9cd8316cb8ad86d4051730fe5cae9 Mon Sep 17 00:00:00 2001 From: Lee Henson Date: Sun, 20 Oct 2013 18:30:58 +0100 Subject: [PATCH 1/2] don't need this ID --- plugins/config/commands | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/config/commands b/plugins/config/commands index 6061698b869..f50321abbc6 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -108,7 +108,6 @@ case "$1" in APP="$2"; APP_DIR="$DOKKU_ROOT/$APP" ENV_ADD="" ENV_TEMP=`cat "${ENV_FILE}"` - ID=$(< "$APP_DIR/CONTAINER") RESTART=false VARS="${*:3}" @@ -151,7 +150,6 @@ case "$1" in APP="$2"; APP_DIR="$DOKKU_ROOT/$APP" ENV_TEMP=`cat "${ENV_FILE}"` - ID=$(< "$APP_DIR/CONTAINER") VARS="${*:3}" for var in $VARS; do From 86ea54d35ae0e78ddab6b4726dedd92d08609613 Mon Sep 17 00:00:00 2001 From: Lee Henson Date: Thu, 7 Nov 2013 13:26:45 +0000 Subject: [PATCH 2/2] extract deploy mechanism into a plugin --- dokku | 17 ++--------------- plugins/01_dokku-deploy/commands | 3 +++ plugins/01_dokku-deploy/run-deploy | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100755 plugins/01_dokku-deploy/commands create mode 100755 plugins/01_dokku-deploy/run-deploy diff --git a/dokku b/dokku index 95b214a2b65..839bc9cf458 100755 --- a/dokku +++ b/dokku @@ -46,21 +46,8 @@ case "$1" in deploy) APP="$2"; IMAGE="$3" pluginhook pre-deploy $APP $IMAGE - - # kill the app when running - if [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then - oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER") - docker kill $oldid > /dev/null - fi - - # start the app - id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web") - echo $id > "$DOKKU_ROOT/$APP/CONTAINER" - port=$(docker port $id 5000 | sed 's/0.0.0.0://') - echo $port > "$DOKKU_ROOT/$APP/PORT" - echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL" - - pluginhook post-deploy $APP $port + pluginhook run-deploy $APP $IMAGE + pluginhook post-deploy $APP $(< "$DOKKU_ROOT/$APP/PORT") ;; cleanup) diff --git a/plugins/01_dokku-deploy/commands b/plugins/01_dokku-deploy/commands new file mode 100755 index 00000000000..143aedbc2ed --- /dev/null +++ b/plugins/01_dokku-deploy/commands @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -eo pipefail +cat diff --git a/plugins/01_dokku-deploy/run-deploy b/plugins/01_dokku-deploy/run-deploy new file mode 100755 index 00000000000..ab563bce47b --- /dev/null +++ b/plugins/01_dokku-deploy/run-deploy @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -eo pipefail + +APP="$1" +IMAGE="$2" + +# kill the app when running +if [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then + oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER") + docker kill $oldid > /dev/null +fi + +# start the app +id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web") +echo $id > "$DOKKU_ROOT/$APP/CONTAINER" +port=$(docker port $id 5000 | sed 's/0.0.0.0://') +echo $port > "$DOKKU_ROOT/$APP/PORT" +echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL"