Fixed port redirection issues

This commit is contained in:
Ahmed Al Hafoudh
2013-10-31 16:13:57 +01:00
parent 0da5065429
commit 9aa5f7a85b

23
dokku
View File

@@ -46,21 +46,20 @@ case "$1" in
deploy)
APP="$2"; IMAGE="$3"
pluginhook pre-deploy $APP $IMAGE
if [[ ! -f "$DOKKU_ROOT/$APP/PORT" ]]; then
# First deploy
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"
else
# Regular deploy
# kill the app when running
if [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
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
# 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
;;