Merge pull request #873 from progrium/870-mh-bind-ip-on-domains-change

support pre deployment usage of domains plugin. fixes interface binding issue
This commit is contained in:
Jose Diaz-Gonzalez
2015-01-06 16:14:02 -05:00
6 changed files with 36 additions and 16 deletions

6
dokku
View File

@@ -88,14 +88,12 @@ case "$1" in
port=5000
id=$(docker run -d -e PORT=$port $DOCKER_ARGS $IMAGE /bin/bash -c "/start web")
ipaddr=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $id)
echo $ipaddr > "$DOKKU_ROOT/$APP/IP"
else
id=$(docker run -d -p 5000 -e PORT=5000 $DOCKER_ARGS $IMAGE /bin/bash -c "/start web")
port=$(docker port $id 5000 | sed 's/[0-9.]*://')
[[ -f "$DOKKU_ROOT/$APP/IP" ]] && rm -f "$DOKKU_ROOT/$APP/IP"
ipaddr=127.0.0.1
fi
echo $ipaddr > "$DOKKU_ROOT/$APP/IP"
# if we can't post-deploy successfully, kill new container
function kill_new {

View File

@@ -15,12 +15,18 @@ restart_nginx () {
case "$1" in
nginx:build-config)
APP="$2"; PORT="$3"; IP="${4:-127.0.0.1}"
[[ -z "$PORT" ]] && PORT=$(< "$DOKKU_ROOT/$APP/PORT")
APP="$2"; PORT="$3"; IP="${4}"
VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
WILDCARD_SSL="$DOKKU_ROOT/tls"
SSL="$DOKKU_ROOT/$APP/tls"
if [[ -z "$PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
PORT=$(< "$DOKKU_ROOT/$APP/PORT")
fi
if [[ -z "$IP" ]] && [[ -f "$DOKKU_ROOT/$APP/IP" ]]; then
IP=$(< "$DOKKU_ROOT/$APP/IP")
fi
[[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV
if [[ ! -n "$NO_VHOST" ]]; then
@@ -67,15 +73,17 @@ EOF
# Include SSL_VHOSTS so we can redirect http to https on that hostname as well
NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS $SSL_VHOSTS| tr '\n' ' ')
echo "-----> Creating $SCHEME nginx.conf"
echo "upstream $APP { server $IP:$PORT; }" > $DOKKU_ROOT/$APP/nginx.conf
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
if [[ -n "$PORT" ]] && [[ -n "$IP" ]]; then
echo "-----> Creating $SCHEME nginx.conf"
echo "upstream $APP { server $IP:$PORT; }" > $DOKKU_ROOT/$APP/nginx.conf
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
echo "-----> Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $PORT
echo "-----> Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $PORT $IP
echo " Reloading nginx"
restart_nginx
echo " Reloading nginx"
restart_nginx
fi
else
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
echo "-----> NO_VHOST set, deleting $APP/VHOST"

View File

@@ -17,7 +17,7 @@ ifdef ENABLE_DOKKU_TRACE
echo "export DOKKU_TRACE=1" >> /home/dokku/dokkurc
endif
@echo "Setting dokku.me in /etc/hosts"
sudo /bin/bash -c "[[ `ping -c1 dokku.me > /dev/null 2>&1; echo $$?` -eq 0 ]] || echo \"127.0.0.1 dokku.me *.dokku.me\" >> /etc/hosts"
sudo /bin/bash -c "[[ `ping -c1 dokku.me > /dev/null 2>&1; echo $$?` -eq 0 ]] || echo \"127.0.0.1 dokku.me *.dokku.me www.test.app.dokku.me\" >> /etc/hosts"
@echo "-----> Generating keypair..."
mkdir -p /root/.ssh

View File

@@ -3,7 +3,7 @@
load test_helper
setup() {
deploy_app
create_app
}
teardown() {

View File

@@ -66,3 +66,17 @@ teardown() {
echo "status: "$status
assert_success
}
@test "port exposure (domains:add)" {
create_app
run dokku domains:add $TEST_APP www.test.app.dokku.me
echo "output: "$output
echo "status: "$status
assert_success
deploy_app
sleep 5 # wait for nginx to reload
run bash -c "response=\"$(curl -s -S www.test.app.dokku.me)\"; echo \$response; test \"\$response\" == \"nodejs/express\""
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -90,7 +90,7 @@ destroy_app() {
deploy_app() {
TMP=$(mktemp -d -t "$TARGET.XXXXX")
rmdir $TMP && cp -r ./tests/apps/config $TMP
rmdir $TMP && cp -r ./tests/apps/nodejs-express $TMP
cd $TMP
git init
git config user.email "robot@example.com"