Merge pull request #279 from alhafoudh/master

Fixed port redirection issues
This commit is contained in:
rhy-jot committed 2013-10-31 14:53:33 -07:00
commit 407c5b2875
1 file changed
+11 -12
+11 -12
View File
@@ -46,21 +46,20 @@ case "$1" in
deploy) deploy)
APP="$2"; IMAGE="$3" APP="$2"; IMAGE="$3"
pluginhook pre-deploy $APP $IMAGE pluginhook pre-deploy $APP $IMAGE
if [[ ! -f "$DOKKU_ROOT/$APP/PORT" ]]; then
# First deploy # kill the app when running
id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web") if [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
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"
else
# Regular deploy
oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER") oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
docker kill $oldid > /dev/null docker kill $oldid > /dev/null
port=$(< "$DOKKU_ROOT/$APP/PORT")
id=$(docker run -d -p ":$port" -e "PORT=$port" $IMAGE /bin/bash -c "/start web")
echo $id > "$DOKKU_ROOT/$APP/CONTAINER"
fi 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 post-deploy $APP $port
;; ;;