From fabb18c55c4d54d870406513d1a20c3c4f9220ec Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 30 Sep 2018 15:33:42 -0400 Subject: [PATCH] feat: allow disabling the nginx-vhosts plugin by default This allows us to force another plugin as the default vhost implementation, or disable it altogether in favor of some higher-level proxy implementation, such as one that integrates with service discovery. --- bootstrap.sh | 1 + contrib/dokku-installer.py | 1 + debian/config | 1 + debian/postinst | 6 +++++- debian/postrm | 5 ++++- debian/templates | 5 +++++ docs/getting-started/install/debian.md | 1 + 7 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 0da17ab04..622928a55 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -173,6 +173,7 @@ install-dokku-from-deb-package() { [[ -n $DOKKU_HOSTNAME ]] && echo "dokku dokku/hostname string $DOKKU_HOSTNAME" | sudo debconf-set-selections [[ -n $DOKKU_SKIP_KEY_FILE ]] && echo "dokku dokku/skip_key_file boolean $DOKKU_SKIP_KEY_FILE" | sudo debconf-set-selections [[ -n $DOKKU_KEY_FILE ]] && echo "dokku dokku/key_file string $DOKKU_KEY_FILE" | sudo debconf-set-selections + [[ -n $DOKKU_NGINX_ENABLE ]] && echo "dokku dokku/nginx_enable string $DOKKU_NGINX_ENABLE" | sudo debconf-set-selections if [[ -n $DOKKU_CHECKOUT ]]; then # shellcheck disable=SC2086 diff --git a/contrib/dokku-installer.py b/contrib/dokku-installer.py index 240900cb6..9fb73bf4b 100755 --- a/contrib/dokku-installer.py +++ b/contrib/dokku-installer.py @@ -120,6 +120,7 @@ class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): proc.stdin.close() proc.wait() + set_debconf_selection('boolean', 'nginx_enable', 'true') set_debconf_selection('boolean', 'skip_key_file', 'true') set_debconf_selection('boolean', 'vhost_enable', vhost_enable) set_debconf_selection('boolean', 'web_config', 'false') diff --git a/debian/config b/debian/config index d988e0516..eab3ea415 100755 --- a/debian/config +++ b/debian/config @@ -17,6 +17,7 @@ if [ $RET = "true" ]; then exit 0 fi +db_input "high" "dokku/nginx_enable" || true db_input "high" "dokku/hostname" || true db_input "high" "dokku/vhost_enable" || true if [ "$ACTION" != "reconfigure" ]; then diff --git a/debian/postinst b/debian/postinst index ac40b8e72..78aa58a91 100755 --- a/debian/postinst +++ b/debian/postinst @@ -59,9 +59,13 @@ case "$1" in fi done + db_get "dokku/nginx_enable" echo "Enabling all core plugins" find ${DOKKU_LIB_ROOT}/core-plugins/available -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do - if [ ! -d ${DOKKU_LIB_ROOT}/plugins/available/$plugin ]; then + if [ "$plugin" = "nginx-vhosts" ] && [ "$RET" = "false" ]; then + echo "Skipping enable of nginx-vhosts plugin" + continue + elif [ ! -d ${DOKKU_LIB_ROOT}/plugins/available/$plugin ]; then ln -s ${DOKKU_LIB_ROOT}/core-plugins/available/$plugin ${DOKKU_LIB_ROOT}/plugins/available/$plugin; PLUGIN_PATH=${DOKKU_LIB_ROOT}/core-plugins plugn enable $plugin PLUGIN_PATH=${DOKKU_LIB_ROOT}/plugins plugn enable $plugin diff --git a/debian/postrm b/debian/postrm index ba0916cb3..f939ee55a 100755 --- a/debian/postrm +++ b/debian/postrm @@ -21,7 +21,10 @@ main() { rm -f /etc/systemd/system/dokku-redeploy.service rm -f /etc/update-motd.d/99-dokku - (nginx -t && service nginx reload) || true + db_get "dokku/nginx_enable" + if [ "$RET" = "true" ]; then + (nginx -t && service nginx reload) || true + fi if [[ "$1" == "purge" ]]; then rm -f /etc/nginx/conf.d/dokku.conf diff --git a/debian/templates b/debian/templates index f3334d60e..e5f314de4 100644 --- a/debian/templates +++ b/debian/templates @@ -22,3 +22,8 @@ Template: dokku/key_file Description: Keyfile for initial user: Type: string Default: /root/.ssh/id_rsa.pub + +Template: dokku/nginx_enable +Description: Enable nginx-vhosts plugin? +Type: boolean +Default: true diff --git a/docs/getting-started/install/debian.md b/docs/getting-started/install/debian.md index 4282d12c3..d902180ce 100644 --- a/docs/getting-started/install/debian.md +++ b/docs/getting-started/install/debian.md @@ -41,3 +41,4 @@ After setting the desired options, proceed with the installation as described ab | dokku/hostname | string | dokku.me | Hostname, used as vhost domain and for showing app URL after deploy | | dokku/skip_key_file| boolean | false | Don't check for the existence of the dokku/key_file. Warning: Setting this to true, will require you to manually add an SSH key later on. | | dokku/key_file | string | /root/.ssh/id_rsa.pub | Path on disk to an SSH key to add to the Dokku user (Will be ignored on `dpkg-reconfigure`) | +| dokku/nginx_enable | boolean | true | Enable nginx-vhosts plugin |