diff --git a/HISTORY.md b/HISTORY.md index 249871d05..5353e30bc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,18 @@ # History +## 0.3.15 + +- #950: @michaelhobbs Do not count blank lines in `make count` +- #952: @michaelhobbs Document cli args over ssh. closes #951 +- #954: @michaelhobbs Dockerfile support +- #955: @michaelhobbs Quick style refactor +- #956: @michaelhobbs Comment out skipped tests as we pay the cost for setup() and teardown() anyway +- #957: @michaelhobbs Implement dokku shell and ls (by @plietar). refs #312 +- #960: @michaelhobbs Use consistent bash shebang. closes #959 +- #962: @josegonzalez Update debian package building due to man page generation changes +- #964: @michaelhobbs Only look for long args in global space. allows for short args in plugins. closes #963 +- #966: @djelic handle upgrade in debian/preinst script + ## 0.3.14 - #891: @josegonzalez Keep existing configuration files when installing nginx. Refs #886 diff --git a/README.md b/README.md index 773c29ed3..e7c1ee3b7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. S To install the latest stable version of dokku, you can run the following bootstrapper command: - $ wget -qO- https://raw.github.com/progrium/dokku/v0.3.14/bootstrap.sh | sudo DOKKU_TAG=v0.3.14 bash + $ wget -qO- https://raw.github.com/progrium/dokku/v0.3.15/bootstrap.sh | sudo DOKKU_TAG=v0.3.15 bash ### Upgrading diff --git a/Vagrantfile b/Vagrantfile index 2d310a943..a2a4e7d9c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -47,6 +47,7 @@ Vagrant::configure("2") do |config| end config.vm.define "build", autostart: false do |vm| + vm.vm.provision :shell, :inline => "apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" vm.vm.provision :shell, :inline => "cd /root/dokku && make deb-all" end diff --git a/contrib/dokku-installer.rb b/contrib/dokku-installer.rb index 2210db7da..4b14c3f2c 100755 --- a/contrib/dokku-installer.rb +++ b/contrib/dokku-installer.rb @@ -21,7 +21,7 @@ if ARGV[0] == "onboot" exit end -version = "v0.3.14" +version = "v0.3.15" dokku_root = ENV["DOKKU_ROOT"] || "/home/dokku" admin_key = `cat /root/.ssh/authorized_keys`.split("\n").first hostname = `bash -c '[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME || curl icanhazip.com'`.strip diff --git a/deb.mk b/deb.mk index 13357eef6..6e3f5917d 100644 --- a/deb.mk +++ b/deb.mk @@ -101,7 +101,9 @@ deb-dokku: deb-setup cp dokku /tmp/build/usr/local/bin cp -r plugins /tmp/build/var/lib/dokku find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do touch /tmp/build/var/lib/dokku/plugins/$$plugin/.core; done - cp dokku.1 /tmp/build/usr/local/share/man/man1/dokku.1 + $(MAKE) help2man + $(MAKE) addman + cp /usr/local/share/man/man1/dokku.1 /tmp/build/usr/local/share/man/man1/dokku.1 cp contrib/dokku-installer.rb /tmp/build/usr/local/share/dokku/contrib git describe --tags > /tmp/build/var/lib/dokku/VERSION cat /tmp/build/var/lib/dokku/VERSION | cut -d '-' -f 1 | cut -d 'v' -f 2 > /tmp/build/var/lib/dokku/STABLE_VERSION diff --git a/debian/preinst b/debian/preinst index a7a5c7a54..198b8aee6 100755 --- a/debian/preinst +++ b/debian/preinst @@ -25,6 +25,9 @@ case "$1" in service nginx reload ;; + upgrade) + ;; + abort-upgrade) ;; diff --git a/docs/installation.md b/docs/installation.md index 7718c0aed..bc4c54752 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -11,7 +11,7 @@ Ubuntu 14.04 x64 x64. Ideally have a domain ready to point to your host. It's de To install the latest stable version of dokku, you can run the following bootstrapper command: ```shell -wget -qO- https://raw.github.com/progrium/dokku/v0.3.14/bootstrap.sh | sudo DOKKU_TAG=v0.3.14 bash +wget -qO- https://raw.github.com/progrium/dokku/v0.3.15/bootstrap.sh | sudo DOKKU_TAG=v0.3.15 bash ``` ## Configuring diff --git a/docs/remote-commands.md b/docs/remote-commands.md index 4bc907359..943ebfa47 100644 --- a/docs/remote-commands.md +++ b/docs/remote-commands.md @@ -24,7 +24,8 @@ Dokku also supports certain command-line arguments that augment it's behavior. I in order to avoid ssh interpretting dokku arguments for itself. ```shell --q|--quiet suppress output headers --t|--trace enable DOKKU_TRACE for current execution only +--quiet suppress output headers +--trace enable DOKKU_TRACE for current execution only --rm|--rm-container remove docker container after successful dokku run +--force force flag. currently used in apps:destroy ``` diff --git a/dokku b/dokku index 00c25f915..905d90733 100755 --- a/dokku +++ b/dokku @@ -19,7 +19,7 @@ source "$PLUGIN_PATH/common/functions" parse_args "$@" for arg in "$@"; do - [[ "$arg" =~ ^-.* ]] && shift 1 + [[ "$arg" =~ ^--.* ]] && shift 1 done ! has_tty && DOKKU_QUIET_OUTPUT=1 @@ -150,7 +150,7 @@ case "$1" in ;; help|'') - echo "Usage: dokku [-q|--quiet|-t|--trace|--rm-container|--rm] COMMAND [command-specific-options]" + echo "Usage: dokku [--quiet|--trace|--rm-container|--rm|--force] COMMAND [command-specific-options]" echo "" echo "Options:" diff --git a/plugins/common/functions b/plugins/common/functions index 9785b7cdd..7c0aa071a 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -98,16 +98,16 @@ is_image_buildstep_based() { parse_args() { for arg in "$@"; do case "$arg" in - --quiet|-q) + --quiet) export DOKKU_QUIET_OUTPUT=1 ;; - --trace|-t) + --trace) export DOKKU_TRACE=1 ;; --rm-container|--rm) export DOKKU_RM_CONTAINER=1 ;; - --force|-f) + --force) export DOKKU_APPS_FORCE_DELETE=1 ;; esac diff --git a/plugins/nginx-vhosts/bind-external-ip b/plugins/nginx-vhosts/bind-external-ip index d4582b3cd..422ddc2f0 100755 --- a/plugins/nginx-vhosts/bind-external-ip +++ b/plugins/nginx-vhosts/bind-external-ip @@ -2,7 +2,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x APP="$1" -set +e; NO_VHOST=$(dokku config:get $APP NO_VHOST); set -e +NO_VHOST=$(dokku config:get $APP NO_VHOST || true) RE_IPV4="([0-9]{1,3}[\.]){3}[0-9]{1,3}" diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 1d0a9db23..a75745871 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -52,14 +52,18 @@ EOF SCHEME="https" SSL_HOSTNAME=$(openssl x509 -in $SSL_INUSE/server.crt -noout -subject | tr '/' '\n' | grep CN= | cut -c4-) - SSL_HOSTNAME=$(echo "$SSL_HOSTNAME" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g') - [[ -z "$(egrep ^"$SSL_HOSTNAME"$ $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME" | sed 's/\\./\./g' >> $VHOST_PATH + if [[ -n "$SSL_HOSTNAME" ]]; then + SSL_HOSTNAME_REGEX=$(echo "$SSL_HOSTNAME" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g') + [[ -z "$(egrep "^${SSL_HOSTNAME_REGEX}$" $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME" >> $VHOST_PATH + fi SSL_HOSTNAME_ALT=$(openssl x509 -in $SSL_INUSE/server.crt -noout -text | grep --after-context=1 '509v3 Subject Alternative Name:' | tail -n 1 | sed -e "s/[[:space:]]*DNS://g" | tr ',' '\n' || true) - SSL_HOSTNAME_ALT=$(echo "$SSL_HOSTNAME_ALT" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g') - [[ -z "$(egrep ^"$SSL_HOSTNAME_ALT"$ $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME_ALT" | sed 's/\\./\./g' >> $VHOST_PATH + if [[ -n "$SSL_HOSTNAME_ALT" ]]; then + SSL_HOSTNAME_ALT_REGEX=$(echo "$SSL_HOSTNAME_ALT" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g') + [[ -z "$(egrep "^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME_ALT" >> $VHOST_PATH + fi - SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0) + SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0) NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0) while read line; do diff --git a/plugins/nginx-vhosts/post-deploy b/plugins/nginx-vhosts/post-deploy index db457b8c7..c803c980b 100755 --- a/plugins/nginx-vhosts/post-deploy +++ b/plugins/nginx-vhosts/post-deploy @@ -3,8 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$(dirname $0)/../common/functions" APP="$1"; PORT="$2"; IP="$3" - -set +e; NO_VHOST=$(dokku config:get $APP NO_VHOST); set -e +NO_VHOST=$(dokku config:get $APP NO_VHOST || true) if [[ -n "$NO_VHOST" ]]; then dokku_log_info1 "NO_VHOST config detected" diff --git a/tests/unit/00_dokku-standard.bats b/tests/unit/00_dokku-standard.bats index c8abfbfba..cb9857e39 100644 --- a/tests/unit/00_dokku-standard.bats +++ b/tests/unit/00_dokku-standard.bats @@ -9,6 +9,7 @@ setup() { teardown() { rm -rf /home/dokku/$TEST_APP/tls /home/dokku/tls destroy_app + disable_tls_wildcard } @test "run (with tty)" { @@ -35,8 +36,7 @@ teardown() { } @test "urls (app ssl)" { - mkdir -p /home/dokku/$TEST_APP/tls - touch /home/dokku/$TEST_APP/tls/server.crt /home/dokku/$TEST_APP/tls/server.key + setup_test_tls run bash -c "dokku urls $TEST_APP | grep dokku.me" echo "output: "$output echo "status: "$status @@ -44,8 +44,7 @@ teardown() { } @test "urls (wildcard ssl)" { - mkdir -p /home/dokku/tls - touch /home/dokku/tls/server.crt /home/dokku/tls/server.key + setup_test_tls_wildcard run bash -c "dokku urls $TEST_APP | grep dokku.me" echo "output: "$output echo "status: "$status diff --git a/tests/unit/nginx-vhosts.bats b/tests/unit/nginx-vhosts.bats index 0c6f09db1..8c9660a48 100644 --- a/tests/unit/nginx-vhosts.bats +++ b/tests/unit/nginx-vhosts.bats @@ -12,6 +12,7 @@ teardown() { destroy_app [[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" + disable_tls_wildcard } @test "nginx (no server tokens)" { @@ -22,6 +23,21 @@ teardown() { assert_failure } +@test "nginx:build-config (wildcard SSL)" { + destroy_app + setup_test_tls_wildcard + create_app + run dokku domains:add $TEST_APP wildcard.dokku.me + echo "output: "$output + echo "status: "$status + assert_success + deploy_app + run bash -c "response=\"$(curl -LkSs wildcard.dokku.me)\"; echo \$response; test \"\$response\" == \"nodejs/express\"" + echo "output: "$output + echo "status: "$status + assert_success +} + @test "nginx:build-config (with SSL CN mismatch)" { setup_test_tls deploy_app diff --git a/tests/unit/server_ssl_wildcard.tar b/tests/unit/server_ssl_wildcard.tar new file mode 100644 index 000000000..0fa52c4ee Binary files /dev/null and b/tests/unit/server_ssl_wildcard.tar differ diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index f3f7a5a7f..08b05c45a 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -134,3 +134,21 @@ setup_test_tls_with_sans() { tar xf $BATS_TEST_DIRNAME/server_ssl_sans.tar -C $TLS sudo chown -R dokku:dokku $TLS } + +setup_test_tls_wildcard() { + TLS="/home/dokku/tls" + mkdir -p $TLS + tar xf $BATS_TEST_DIRNAME/server_ssl_wildcard.tar -C $TLS + sudo chown -R dokku:dokku $TLS + sed -i -e "s:^# ssl_certificate $DOKKU_ROOT/tls/server.crt;:ssl_certificate $DOKKU_ROOT/tls/server.crt;:g" \ + -e "s:^# ssl_certificate_key $DOKKU_ROOT/tls/server.key;:ssl_certificate_key $DOKKU_ROOT/tls/server.key;:g" /etc/nginx/conf.d/dokku.conf + kill -HUP "$(< /var/run/nginx.pid)"; sleep 5 +} + +disable_tls_wildcard() { + TLS="/home/dokku/tls" + rm -rf $TLS + sed -i -e "s:^ssl_certificate $DOKKU_ROOT/tls/server.crt;:# ssl_certificate $DOKKU_ROOT/tls/server.crt;:g" \ + -e "s:^ssl_certificate_key $DOKKU_ROOT/tls/server.key;:# ssl_certificate_key $DOKKU_ROOT/tls/server.key;:g" /etc/nginx/conf.d/dokku.conf + kill -HUP "$(< /var/run/nginx.pid)"; sleep 5 +}