From c316f59f4fb71eb3e674a9fa9f7cb91853a1c348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Mon, 29 Jun 2015 12:25:53 +0200 Subject: [PATCH 01/18] Allows to skip checks (all or default) Setting `DOKKU_SKIP_ALL_CHECKS` globally or for a given app will skip all checks. Setting `DOKKU_SKIP_DEFAULT_CHECKS` globally or for a given app will skip default checks only. --- docs/application-deployment.md | 2 ++ dokku | 15 +++++++++++---- plugins/checks/check-deploy | 4 ++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/application-deployment.md b/docs/application-deployment.md index 11ab783c1..e108c8c18 100644 --- a/docs/application-deployment.md +++ b/docs/application-deployment.md @@ -129,6 +129,8 @@ Dokku will wait `DOKKU_WAIT_TO_RETIRE` seconds (default: `60`) before stopping t Dokku will retry the checks DOKKU_CHECKS_ATTEMPTS times until the checks are successful or DOKKU_CHECKS_ATTEMPTS is exceeded. In the latter case, the deployment is considered failed. This can be overridden in the CHECKS file by setting ATTEMPTS=nn. +Checks can be skipped entirely by setting `DOKKU_SKIP_ALL_CHECKS` to `true` either globally or per application. You can choose to skip only default checks by setting `DOKKU_SKIP_DEFAULT_CHECKS` to `true` either globally or per application. + See [checks-examples.md](checks-examples.md) for examples and output. # Removing a deployed app diff --git a/dokku b/dokku index 6316a5a5e..5f7458c51 100755 --- a/dokku +++ b/dokku @@ -70,6 +70,9 @@ case "$1" in DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE" oldids=$(get_container_ids $APP) + [[ -f "$DOKKU_ROOT/ENV" ]] && source $DOKKU_ROOT/ENV + [[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV + while read line || [ -n "$line" ] do PROC_TYPE=${line%%=*} @@ -111,10 +114,14 @@ case "$1" in } # run checks first, then post-deploy hooks, which switches Nginx traffic - trap kill_new INT TERM EXIT - dokku_log_info1 "Running pre-flight checks" - pluginhook check-deploy $APP $id $PROC_TYPE $port $ipaddr - trap - INT TERM EXIT + if [[ "$DOKKU_SKIP_ALL_CHECKS" = "true" ]]; then + dokku_log_info1 "Skipping pre-flight checks" + else + trap kill_new INT TERM EXIT + dokku_log_info1 "Running pre-flight checks" + pluginhook check-deploy $APP $id $PROC_TYPE $port $ipaddr + trap - INT TERM EXIT + fi # now using the new container [[ -n "$id" ]] && echo $id > "$DOKKU_CONTAINER_ID_FILE" diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index dbeac5b0a..bea6f6b8e 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -79,6 +79,10 @@ cleanup() { trap cleanup EXIT if [[ ! -s "${TMPDIR}/CHECKS" ]] || [[ "$DOKKU_APP_CONTAINER_TYPE" != "web" ]]; then + if [[ "$DOKKU_SKIP_DEFAULT_CHECKS" = "true" ]]; then + dokku_log_verbose "Skipping default check..." + exit 0 + fi dokku_log_verbose "For more efficient zero downtime deployments, create a file CHECKS." dokku_log_verbose "See http://progrium.viewdocs.io/dokku/checks-examples.md for examples" dokku_log_verbose "CHECKS file not found in container: Running simple container check..." From 53e962cd736eba6ad5635b96f9d7ac54cef04386 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 4 Jul 2015 03:28:47 -0400 Subject: [PATCH 02/18] Move primecache to deprecated plugins [ci skip] --- docs/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins.md b/docs/plugins.md index 4204b554c..cdbdba5a9 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -194,7 +194,6 @@ Note: The following plugins have been supplied by our community and may not have | [Logspout](https://github.com/michaelshobbs/dokku-logspout) | [michaelshobbs][] | | | [Node](https://github.com/pnegahdar/dokku-node) | [pnegahdar][] | | | [Node](https://github.com/ademuk/dokku-nodejs) | [ademuk][] | | -| [PrimeCache](https://github.com/darkpixel/dokku-prime-cache) | [darkpixel][] | | | [Rails logs](https://github.com/Flink/dokku-rails-logs) | [Flink][] | | | [Slack Notifications](https://github.com/ribot/dokku-slack) | [ribot][] | | | [User ACL](https://github.com/mlebkowski/dokku-acl) | [Maciej Łebkowski][] | | @@ -217,6 +216,7 @@ The following plugins have been removed as their functionality is now in Dokku C | [Multiple Domains](https://github.com/wmluke/dokku-domains-plugin)1 | [wmluke][] | v0.3.10 (domains plugin) | | [Nginx-Alt](https://github.com/mikexstudios/dokku-nginx-alt) | [mikexstudios][] | v0.3.10 (domains plugin) | | [Persistent Storage](https://github.com/dyson/dokku-persistent-storage) | [dyson][] | v0.3.17 (docker-options plugin) | +| [PrimeCache](https://github.com/darkpixel/dokku-prime-cache) | [darkpixel][] | v0.3.0 (zero downtime deploys) | | [Rebuild application](https://github.com/scottatron/dokku-rebuild) | [scottatron][] | v0.3.14 (ps plugin) | | [Supply env vars to buildpacks](https://github.com/cameron-martin/dokku-build-env)2 | [cameron-martin][] | v0.3.9 (build-env plugin) | | [user-env-compile](https://github.com/musicglue/dokku-user-env-compile)2 | [musicglue][] | v0.3.9 (build-env plugin) | From ecabbc166e8e4d6da3546822abd9ccb8ae4a7d10 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Sun, 5 Jul 2015 18:32:56 +0100 Subject: [PATCH 03/18] Rename dokku-events-logs.md according to index.md Presently the following link is dangling: - http://progrium.viewdocs.io/dokku/dokku-events-logs --- docs/{dokku-event-logs.md => dokku-events-logs.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{dokku-event-logs.md => dokku-events-logs.md} (100%) diff --git a/docs/dokku-event-logs.md b/docs/dokku-events-logs.md similarity index 100% rename from docs/dokku-event-logs.md rename to docs/dokku-events-logs.md From 0b9ac9a72797cf5787e7f19ad1fa517a975950e3 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Sun, 5 Jul 2015 21:08:47 -0700 Subject: [PATCH 04/18] don't background cleanup --- dokku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dokku b/dokku index 15a1ccdd4..56e06f169 100755 --- a/dokku +++ b/dokku @@ -174,7 +174,7 @@ case "$1" in cleanup) # delete all non-running container # shellcheck disable=SC2046 - docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null & + docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null || true # delete unused images # shellcheck disable=SC2046 docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null & From a84397895a4def350d48226ba623d9f3f3881028 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Mon, 6 Jul 2015 19:41:17 -0700 Subject: [PATCH 05/18] initial pass at config plugin arguments refactor --- dokku | 8 +- plugins/00_dokku-standard/commands | 12 +-- plugins/20_events/commands | 8 +- plugins/apps/commands | 6 +- plugins/backup/commands | 4 +- plugins/config/commands | 117 +++++++++++++++-------------- plugins/docker-options/commands | 8 +- plugins/domains/commands | 8 +- plugins/nginx-vhosts/commands | 4 +- plugins/ps/commands | 16 ++-- plugins/shell/commands | 2 +- tests/unit/config.bats | 44 ++++++++++- 12 files changed, 143 insertions(+), 94 deletions(-) diff --git a/dokku b/dokku index 56e06f169..c8232cb15 100755 --- a/dokku +++ b/dokku @@ -208,10 +208,10 @@ case "$1" in echo "Options:" cat< [-t] Show the last logs for an application (-t follows) - run Run a command in the environment of an application - url Show the first URL for an application (compatibility) - urls Show all URLs for an application - version Print dokku's version + ls Pretty listing of deployed applications and containers + logs [-t] Show the last logs for an application (-t follows) + run Run a command in the environment of an application + url Show the first URL for an application (compatibility) + urls Show all URLs for an application + version Print dokku's version EOF ;; diff --git a/plugins/20_events/commands b/plugins/20_events/commands index 62f0ea475..ad96119e5 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -40,10 +40,10 @@ case "$1" in help | events:help) cat && cat< Create a new app - apps:destroy Permanently destroy an app + apps List your apps + apps:create Create a new app + apps:destroy Permanently destroy an app EOF ;; diff --git a/plugins/backup/commands b/plugins/backup/commands index 3eacdde2a..8d44e1438 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -87,8 +87,8 @@ case "$1" in help | backup:help) cat && cat< $ENV_FILE_TEMP if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then cp -f $ENV_FILE_TEMP $ENV_FILE @@ -46,14 +48,36 @@ config_write() { rm -f $ENV_FILE_TEMP } +parse_config_args() { + case "$2" in + --global) + ENV_FILE="$DOKKU_ROOT/ENV" + DOKKU_CONFIG_TYPE="global" + DOKKU_CONFIG_RESTART=false + ;; + --no-restart) + ARGS=("$@") && shift 2 + DOKKU_CONFIG_RESTART=false dokku ${ARGS[0]} "$@" + exit 0 + ;; + *) + ENV_FILE="$DOKKU_ROOT/$2/ENV" + DOKKU_CONFIG_TYPE="app" + + [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + verify_app_name "$2" + APP="$2" + ;; + esac +} + case "$1" in config) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - verify_app_name "$2" - APP="$2" - + parse_config_args "$@" config_create - [[ ! -s $ENV_FILE ]] && echo "$APP has no config vars" && exit 1 + + [[ "$APP" ]] && DOKKU_CONFIG_TYPE=$APP + [[ ! -s $ENV_FILE ]] && echo "no config vars for $DOKKU_CONFIG_TYPE" && exit 1 VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-) @@ -64,14 +88,13 @@ case "$1" in fi done - dokku_log_info2_quiet "$APP config vars" + + dokku_log_info2_quiet "$DOKKU_CONFIG_TYPE config vars" config_styled_hash "$VARS" ;; config:get) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - verify_app_name "$2" - APP="$2" + parse_config_args "$@" if [[ -z $3 ]]; then echo "Usage: dokku config:get APP KEY" @@ -90,26 +113,7 @@ case "$1" in ;; config:set) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - verify_app_name "$2" - APP="$2" - - if [[ -z "${*:3}" ]]; then - echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]" - echo "Must specify KEY and VALUE to set." - exit 1 - fi - - shift 2 - dokku config:set-norestart $APP "$@" - dokku_log_info1 "Restarting app $APP" - dokku ps:restart $APP - ;; - - config:set-norestart) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - verify_app_name "$2" - APP="$2" + parse_config_args "$@" if [[ -z "${*:3}" ]]; then echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]" @@ -153,29 +157,15 @@ ${var}" config_write "$ENV_TEMP" fi + + if [[ "$DOKKU_CONFIG_RESTART" == "true" ]]; then + dokku_log_info1 "Restarting app $APP" + dokku ps:restart $APP + fi ;; config:unset) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - verify_app_name "$2" - APP="$2" - - if [[ -z $3 ]]; then - echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]" - echo "Must specify KEY to unset." - exit 1 - fi - - shift 2 - dokku config:unset-norestart $APP "$@" - dokku_log_info1 "Restarting app $APP" - dokku ps:restart $APP - ;; - - config:unset-norestart) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - verify_app_name "$2" - APP="$2" + parse_config_args "$@" if [[ -z $3 ]]; then echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]" @@ -193,14 +183,31 @@ ${var}" config_write "$ENV_TEMP" done + + if [[ "$DOKKU_CONFIG_RESTART" == "true" ]]; then + dokku_log_info1 "Restarting app $APP" + dokku ps:restart $APP + fi + ;; + + config:set-norestart) + dokku_log_info2 "$1 is deprecated as of v0.3.22" + shift 1 + dokku config:set --no-restart "$@" + ;; + + config:unset-norestart) + dokku_log_info2 "$1 is deprecated as of v0.3.22" + shift 1 + dokku config:unset --no-restart "$@" ;; help | config:help) cat && cat< Display the config vars for an app - config:get KEY Display a config value for an app - config:set KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars - config:unset KEY1 [KEY2 ...] Unset one or more config vars + config (|--global) Display all global or app-specific config vars + config:get (|--global) KEY Display a global or app-specific config value + config:set (|--global) KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars + config:unset (|--global) KEY1 [KEY2 ...] Unset one or more config vars EOF ;; diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index d3eb5a9eb..377fcfd5d 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -141,10 +141,10 @@ case "$1" in # Display usage help help) cat && cat< Display apps docker options for all phases - docker-options Display apps docker options for phase (comma seperated phase list) - docker-options:add OPTION Add docker option to app for phase (comma seperated phase list) - docker-options:remove OPTION Remove docker option from app for phase (comma seperated phase list) + docker-options Display apps docker options for all phases + docker-options Display apps docker options for phase (comma seperated phase list) + docker-options:add OPTION Add docker option to app for phase (comma seperated phase list) + docker-options:remove OPTION Remove docker option from app for phase (comma seperated phase list) EOF ;; diff --git a/plugins/domains/commands b/plugins/domains/commands index 5de0f426d..4b2297bdf 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -133,10 +133,10 @@ case "$1" in help | domains:help) cat && cat< List custom domains for app - domains:add DOMAIN Add a custom domain to app - domains:clear Clear all custom domains for app - domains:remove DOMAIN Remove a custom domain from app + domains List custom domains for app + domains:add DOMAIN Add a custom domain to app + domains:clear Clear all custom domains for app + domains:remove DOMAIN Remove a custom domain from app EOF ;; diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 126c096cd..abb9a94de 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -167,8 +167,8 @@ EOF help | nginx:help) cat && cat< Imports a tarball from stdin; should contain server.crt and server.key - nginx:build-config (Re)builds nginx config for given app + nginx:import-ssl Imports a tarball from stdin; should contain server.crt and server.key + nginx:build-config (Re)builds nginx config for given app EOF ;; diff --git a/plugins/ps/commands b/plugins/ps/commands index 92e28d1cc..f5b824643 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -105,14 +105,14 @@ case "$1" in help | ps:help) cat && cat< List processes running in app container(s) - ps:scale = [=] Set how many processes of a given process to run - ps:start Start app container(s) - ps:stop Stop app container(s) - ps:rebuild Rebuild an app - ps:rebuildall Rebuild all apps - ps:restart Restart app container(s) - ps:restartall Restart all deployed app containers + ps List processes running in app container(s) + ps:scale = [=] Set how many processes of a given process to run + ps:start Start app container(s) + ps:stop Stop app container(s) + ps:rebuild Rebuild an app + ps:rebuildall Rebuild all apps + ps:restart Restart app container(s) + ps:restartall Restart all deployed app containers EOF ;; diff --git a/plugins/shell/commands b/plugins/shell/commands index c6dca6ffe..3b1d6d60b 100755 --- a/plugins/shell/commands +++ b/plugins/shell/commands @@ -48,7 +48,7 @@ case "$1" in help | shell:help) cat && cat< $DOKKU_ROOT/ENV" create_app } teardown() { destroy_app - rm -f "$DOKKU_ROOT/ENV" + [[ -f $DOKKU_ROOT/ENV.bak ]] && mv -f $DOKKU_ROOT/ENV.bak $DOKKU_ROOT/ENV +} + +@test "(config) config:set --global" { + run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "(config) config:get --global" { + run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\" test_var3=\"with\\nnewline\" + echo "output: "$output + echo "status: "$status + assert_success + run dokku config:get --global test_var2 + echo "output: "$output + echo "status: "$status + assert_output 'hello world' + run dokku config:get --global test_var3 + echo "output: "$output + echo "status: "$status + assert_output 'with\nnewline' +} + +@test "(config) config:unset --global" { + run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\" + echo "output: "$output + echo "status: "$status + assert_success + run dokku config:get --global test_var + echo "output: "$output + echo "status: "$status + assert_success + run dokku config:unset --global test_var + echo "output: "$output + echo "status: "$status + assert_success + run dokku config:get --global test_var + echo "output: "$output + echo "status: "$status + assert_output "" } @test "(config) config:set" { From 710c6f4e8839f3f499df85a19d41fd40be98bcfc Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Tue, 7 Jul 2015 12:31:57 -0700 Subject: [PATCH 06/18] don't run dokku again on --* args in config plugin --- plugins/config/commands | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/plugins/config/commands b/plugins/config/commands index 8d0d60f34..fd672833e 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -2,8 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$(dirname $0)/../common/functions" -DOKKU_CONFIG_RESTART=${DOKKU_CONFIG_RESTART:=true} - config_create () { [ -f $ENV_FILE ] || { touch $ENV_FILE @@ -24,7 +22,7 @@ config_styled_hash () { while read -r word; do KEY=$(echo $word | cut -d"=" -f1) - VALUE=$(echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//") + VALUE=$(echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//" -e "s/\$$//g") num_zeros=$((${#longest} - ${#KEY})) zeros=" " @@ -56,19 +54,26 @@ parse_config_args() { DOKKU_CONFIG_RESTART=false ;; --no-restart) - ARGS=("$@") && shift 2 - DOKKU_CONFIG_RESTART=false dokku ${ARGS[0]} "$@" - exit 0 - ;; - *) - ENV_FILE="$DOKKU_ROOT/$2/ENV" + APP="$3" + ENV_FILE="$DOKKU_ROOT/$APP/ENV" + DOKKU_CONFIG_RESTART=false DOKKU_CONFIG_TYPE="app" + set -- "${@:1:1}" "${@:3}" + esac - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + APP=${APP:="$2"} + ENV_FILE=${ENV_FILE:="$DOKKU_ROOT/$APP/ENV"} + DOKKU_CONFIG_TYPE=${DOKKU_CONFIG_TYPE:="app"} + DOKKU_CONFIG_RESTART=${DOKKU_CONFIG_RESTART:=true} + + if [[ "$DOKKU_CONFIG_TYPE" = "app" ]]; then + if [[ -z $APP ]]; then + echo "Please specify an app to run the command on" >&2 && exit 1 + else verify_app_name "$2" - APP="$2" - ;; - esac + fi + fi + export APP ENV_FILE DOKKU_CONFIG_TYPE DOKKU_CONFIG_RESTART } case "$1" in @@ -114,6 +119,7 @@ case "$1" in config:set) parse_config_args "$@" + [[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}" if [[ -z "${*:3}" ]]; then echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]" @@ -166,6 +172,7 @@ ${var}" config:unset) parse_config_args "$@" + [[ "$2" = "--no-restart" ]] && set -- "${@:1:1}" "${@:3}" if [[ -z $3 ]]; then echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]" From 54b46066ff32e45fdcb3db625cab2e2a0e70d245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Thu, 9 Jul 2015 12:26:59 +0200 Subject: [PATCH 07/18] Add docker-auto-volumes to plugins --- docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/plugins.md b/docs/plugins.md index cdbdba5a9..018701a0d 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -189,6 +189,7 @@ Note: The following plugins have been supplied by our community and may not have | [Bower/Grunt](https://github.com/thrashr888/dokku-bower-grunt-build-plugin) | [thrashr888][] | | | [Bower/Gulp](https://github.com/gdi2290/dokku-bower-gulp-build-plugin) | [gdi2290][] | | | [Bower/Gulp](https://github.com/jagandecapri/dokku-bower-gulp-build-plugin) | [jagandecapri][] | | +| [Docker auto volumes](https://github.com/Flink/dokku-docker-auto-volumes) | [Flink][] | 0.3.17+, auto-persist docker volumes | | [HipChat Notifications](https://github.com/cef/dokku-hipchat) | [cef][] | | | [Graphite/statsd](https://github.com/jlachowski/dokku-graphite-plugin) | [jlachowski][] | | | [Logspout](https://github.com/michaelshobbs/dokku-logspout) | [michaelshobbs][] | | From 033a267573449b0cef68d9b786441d60a79fbb15 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Thu, 9 Jul 2015 12:12:49 -0700 Subject: [PATCH 08/18] fix urls command when NO_VHOST=1 + tests. fixes #1294 --- plugins/00_dokku-standard/commands | 4 +- plugins/nginx-vhosts/commands | 4 ++ tests/unit/core_ports.bats | 63 ++++++++++++++++++++++-------- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index e6c6d5751..381f8d06c 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -180,6 +180,8 @@ case "$1" in verify_app_name "$2" APP="$2"; + [[ "$DOKKU_ROOT/$APP/ENV" ]] && source "$DOKKU_ROOT/$APP/ENV" + if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then case "$1" in url) @@ -198,7 +200,7 @@ case "$1" in SCHEME="https" fi - if [[ -f "$DOKKU_ROOT/VHOST" ]]; then + if [[ -f "$DOKKU_ROOT/VHOST" ]] && [[ "$NO_VHOST" != "1" ]]; then echo "$SCHEME://$(< "$DOKKU_ROOT/VHOST")" else for PORT_FILE in $DOKKU_ROOT/$APP/PORT.*; do diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 126c096cd..d00fd3aa5 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -133,6 +133,10 @@ EOF dokku_log_info1 "VHOST support disabled, deleting $APP/VHOST" rm "$DOKKU_ROOT/$APP/VHOST" fi + if [[ -f "$DOKKU_ROOT/$APP/URLS" ]]; then + dokku_log_info1 "VHOST support disabled, deleting $APP/URLS" + rm "$DOKKU_ROOT/$APP/URLS" + fi if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then dokku_log_info1 "VHOST support disabled, deleting nginx.conf" rm "$DOKKU_ROOT/$APP/nginx.conf" diff --git a/tests/unit/core_ports.bats b/tests/unit/core_ports.bats index 437732b79..c2a6b657d 100644 --- a/tests/unit/core_ports.bats +++ b/tests/unit/core_ports.bats @@ -13,57 +13,80 @@ teardown() { [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" } + +check_urls() { + local PATTERN="$1" + run bash -c "dokku --quiet urls $TEST_APP | egrep \"${1}\"" + echo "output: "$output + echo "status: "$status + assert_success +} + @test "(core) port exposure (with global VHOST)" { echo "dokku.me" > "$DOKKU_ROOT/VHOST" deploy_app - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_failure + + check_urls http://${TEST_APP}.dokku.me } @test "(core) port exposure (without global VHOST and real HOSTNAME)" { rm "$DOKKU_ROOT/VHOST" - echo "dokku.me" > "$DOKKU_ROOT/HOSTNAME" + echo "${TEST_APP}.dokku.me" > "$DOKKU_ROOT/HOSTNAME" deploy_app - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_success + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ } @test "(core) port exposure (with NO_VHOST set)" { deploy_app dokku config:set $TEST_APP NO_VHOST=1 - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }' | head -1) - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_success + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ } @test "(core) port exposure (without global VHOST and IPv4 address as HOSTNAME)" { rm "$DOKKU_ROOT/VHOST" echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME" deploy_app - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_success + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ } @test "(core) port exposure (without global VHOST and IPv6 address as HOSTNAME)" { rm "$DOKKU_ROOT/VHOST" echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME" deploy_app - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_success + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ } @test "(core) port exposure (pre-deploy domains:add)" { @@ -76,8 +99,8 @@ teardown() { deploy_app sleep 5 # wait for nginx to reload - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_failure @@ -86,6 +109,8 @@ teardown() { echo "output: "$output echo "status: "$status assert_success + + check_urls http://www.test.app.dokku.me } @test "(core) port exposure (no global VHOST and domains:add post deploy)" { @@ -102,8 +127,8 @@ teardown() { echo "status: "$status assert_success - CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }' | head -1) - run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" + CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'" echo "output: "$output echo "status: "$status assert_failure @@ -112,14 +137,18 @@ teardown() { echo "output: "$output echo "status: "$status assert_success + + check_urls http://www.test.app.dokku.me } @test "(core) dockerfile port exposure" { deploy_app dockerfile - run bash -c "grep -A1 upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep 3000" + run bash -c "grep -A1 upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep -q 3000" echo "output: "$output echo "status: "$status assert_success + + check_urls http://${TEST_APP}.dokku.me } @test "(core) port exposure (xip.io style hostnames)" { @@ -130,4 +159,6 @@ teardown() { echo "output: "$output echo "status: "$status assert_success + + check_urls http://my-cool-guy-test-app.127.0.0.1.xip.io } From e21b730089d781bba32c6e529b31d617a79b4fa6 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Thu, 9 Jul 2015 12:31:58 -0700 Subject: [PATCH 09/18] remove dead test file --- tests/unit/backup.bats | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 tests/unit/backup.bats diff --git a/tests/unit/backup.bats b/tests/unit/backup.bats deleted file mode 100644 index 1a3bb19a5..000000000 --- a/tests/unit/backup.bats +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bats - -# load test_helper - -# setup() { -# create_app -# backup_file=$(mktemp /tmp/backup.XXXXXX) -# rm $backup_file -# } - -# teardown() { -# destroy_app -# } - -# @test "(backup) backup:export" { -# run dokku backup:export $backup_file -# echo "output: "$output -# echo "status: "$status -# assert_success -# } From 64d76724e5dadf313211524ec27bca0f4a81eebb Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Thu, 9 Jul 2015 12:35:43 -0700 Subject: [PATCH 10/18] fix typo. good thing we have a test suite. :P --- plugins/00_dokku-standard/commands | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 381f8d06c..7bb63b9dc 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -180,7 +180,7 @@ case "$1" in verify_app_name "$2" APP="$2"; - [[ "$DOKKU_ROOT/$APP/ENV" ]] && source "$DOKKU_ROOT/$APP/ENV" + [[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source "$DOKKU_ROOT/$APP/ENV" if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then case "$1" in From a60dfd3b5e2d678a3b794c9592d5c7ea85a674e5 Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Thu, 9 Jul 2015 18:11:03 +0200 Subject: [PATCH 11/18] Set X-Forwarded-Proto header if TLS is enabled when running checks --- plugins/checks/check-deploy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index dbeac5b0a..b6413ef14 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -125,6 +125,11 @@ do # --location Follow redirects CURL_OPTIONS="-q --compressed --fail --location --max-time $TIMEOUT" + # Set X-Forwarded-Proto header if TLS is enabled. + SSL="$DOKKU_ROOT/$APP/tls"; WILDCARD_SSL="$DOKKU_ROOT/tls" + if [[ -e "$SSL/server.crt" && -e "$SSL/server.key" ]] || [[ -e "$WILDCARD_SSL/server.crt" && -e "$WILDCARD_SSL/server.key" ]]; then + CURL_OPTIONS+=" -H X-Forwarded-Proto:https" + fi exec < "$FILENAME" while read CHECK_URL EXPECTED ; do From 4de6bbfb299bab81036138c83c830097c6ab0166 Mon Sep 17 00:00:00 2001 From: mixxorz Date: Fri, 10 Jul 2015 11:21:43 +0800 Subject: [PATCH 12/18] Added reset-mtime plugin to plugins.md --- docs/plugins.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/plugins.md b/docs/plugins.md index 018701a0d..c2951af1e 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -82,6 +82,7 @@ Note: The following plugins have been supplied by our community and may not have [ribot]: https://github.com/ribot [Benjamin-Dobell]: https://github.com/Benjamin-Dobell [jagandecapri]: https://github.com/jagandecapri +[mixxorz]: https://github.com/mixxorz ### Datastores @@ -196,6 +197,7 @@ Note: The following plugins have been supplied by our community and may not have | [Node](https://github.com/pnegahdar/dokku-node) | [pnegahdar][] | | | [Node](https://github.com/ademuk/dokku-nodejs) | [ademuk][] | | | [Rails logs](https://github.com/Flink/dokku-rails-logs) | [Flink][] | | +| [Reset mtime](https://github.com/mixxorz/dokku-docker-reset-mtime) | [mixxorz][] | 0.3.15+, Dockerfile support | | [Slack Notifications](https://github.com/ribot/dokku-slack) | [ribot][] | | | [User ACL](https://github.com/mlebkowski/dokku-acl) | [Maciej Łebkowski][] | | | [Webhooks](https://github.com/nickstenning/dokku-webhooks) | [nickstenning][] | | From ae2779e38c77621abeba9bf42fc72ff7f9a303dc Mon Sep 17 00:00:00 2001 From: mixxorz Date: Fri, 10 Jul 2015 11:23:49 +0800 Subject: [PATCH 13/18] Fixed missing author links --- docs/plugins.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/plugins.md b/docs/plugins.md index c2951af1e..d78f1fb97 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -83,6 +83,8 @@ Note: The following plugins have been supplied by our community and may not have [Benjamin-Dobell]: https://github.com/Benjamin-Dobell [jagandecapri]: https://github.com/jagandecapri [mixxorz]: https://github.com/mixxorz +[Maciej Łebkowski]: https://github.com/mlebkowski +[abossard]: https://github.com/dudagroup ### Datastores From bff273d625554ce43dbb5515172ddde9a759ef98 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Fri, 10 Jul 2015 12:08:29 +0200 Subject: [PATCH 14/18] in nginx doc, mention where original templates are found by default. --- docs/nginx.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nginx.md b/docs/nginx.md index 6f87d4bbb..1bc9ca8be 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -56,7 +56,7 @@ This archive should is expanded via `tar xvf`. It should contain `server.crt` an > New as of 0.3.10 -Dokku currently templates out an nginx configuration that is included in the `nginx-vhosts` plugin. If you'd like to provide a custom template for your application, you should copy the existing template - ssl or non-ssl - into your `$DOKKU_ROOT/$APP` directory at the file `nginx.conf.template`. +Dokku currently templates out an nginx configuration that is included in the `nginx-vhosts` plugin. If you'd like to provide a custom template for your application, you should copy the existing template - ssl or non-ssl - into your `$DOKKU_ROOT/$APP` directory at the file `nginx.conf.template`. If you followed the default installation path, the original templates are found in `/var/lib/dokku/plugins/nginx-vhosts/templates/nginx{.ssl,}.conf.template` . For instance - assuming defaults - to customize the nginx template in use for the `myapp` application, create a file at `/home/dokku/myapp/nginx.conf.template` with the following contents: From bf1ff080b693ce2e3bed2171ba10645d71e8d499 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Fri, 10 Jul 2015 12:21:29 +0200 Subject: [PATCH 15/18] in nginx conf mention how to apply template changes (i assume deploy is the answer). --- docs/nginx.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/nginx.md b/docs/nginx.md index 1bc9ca8be..8a49aa3a9 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -94,6 +94,8 @@ A few tips for custom nginx templates: - Templated files will be validated via `nginx -t`. - Application environment variables can be used within your nginx configuration. +After your changes a `dokku reploy myapp` will regenerate the `/home/dokku/myapp/nginx.conf` file which is then used. + ## Customizing hostnames Applications typically have the following structure for their hostname: From f68b126bc9a82ffa58d75df8c217f939f2a1c702 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Fri, 10 Jul 2015 12:22:07 +0200 Subject: [PATCH 16/18] fix typo --- docs/nginx.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nginx.md b/docs/nginx.md index 8a49aa3a9..154dc3635 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -94,7 +94,7 @@ A few tips for custom nginx templates: - Templated files will be validated via `nginx -t`. - Application environment variables can be used within your nginx configuration. -After your changes a `dokku reploy myapp` will regenerate the `/home/dokku/myapp/nginx.conf` file which is then used. +After your changes a `dokku deploy myapp` will regenerate the `/home/dokku/myapp/nginx.conf` file which is then used. ## Customizing hostnames From 815bc326a48a082c4c9aa0387f82e6312c0c96f7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Jul 2015 14:43:43 -0400 Subject: [PATCH 17/18] Clarify web/cli installation docs. Closes #1177. Closes #1170 [ci skip] --- docs/installation.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index 4f905eb99..1f8833aba 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -15,7 +15,8 @@ To install the latest stable version of dokku, you can run the following bootstr wget https://raw.github.com/progrium/dokku/v0.3.21/bootstrap.sh sudo DOKKU_TAG=v0.3.21 bash bootstrap.sh -# Go to your server's IP and follow the web installer +# By default, this will do cli-based setup, though you may *also* +# go to your server's IP and follow the web installer ``` For various reasons, certain hosting providers may have other steps that should be preferred to the above. If hosted on any of the following popular hosts, please follow the linked to instructions: From 972cad77177a0e4d91ea98643c5a4364fcd29b97 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Jul 2015 15:00:23 -0400 Subject: [PATCH 18/18] Add release documentation. Closes #1287 [ci skip] --- docs/development/release-process.md | 68 +++++++++++++++++++++++++++++ docs/index.md | 1 + 2 files changed, 69 insertions(+) create mode 100644 docs/development/release-process.md diff --git a/docs/development/release-process.md b/docs/development/release-process.md new file mode 100644 index 000000000..a50e85303 --- /dev/null +++ b/docs/development/release-process.md @@ -0,0 +1,68 @@ +# Release Process + +Dokku is released in intervals *at most* three weeks apart, though may be released much quicker. + +To propose a release, the following tasks need to be performed: + +- The installable version must be changed in the `docs/installation.md` file. +- The installable version must be changed in the `README.md` file. +- The installable version must be changed in the `contrib/dokku-installer.rb` file. +- A list of changes must be made in the `HISTORY.md`. +- A tag must be created locally with your release version +- Debian packages *must* be created via `vagrant up build` +- The packages should be uploaded to packagecloud.io +- All changes are pushed to master and the tag should be turned into a release which will contain the changelog. + +## Versioning + +Dokku follows semver standards. As we are not yet at a stable release, breaking changes will require *only* a minor release, while all other changes only require a patch release. Once we hit stable, breaking changes will require a major release. + +Tags should be created via the following method: + +```shell +git tag v0.9.9 +``` + +At the moment, tags need not be signed, though that may change in the future. + +## Debian Packages + +The `build` target in the dokku `Vagrantfile` creates debian packages for dokku at a point in time. The version will be based upon the latest local tag - you may create your own, internal tags/releases if that is so desired. + +Debian package information is held in the `debian` directory of the dokku project. + +For the public project, releases should be pushed to packagecloud.io *after* a tag is created but *before* said tag is pushed to github. The following may be the release workflow: + + +```shell +git tag v0.9.9 +vagrant up build +export PACKAGECLOUD_TOKEN=SOME_TOKEN +package_cloud push dokku/dokku/ubuntu/trusty dokku_0.9.9_amd64.deb +``` + +If new versions of other packages were created, these should also be pushed at this time. + +> If you are a maintainer and need the PACKAGECLOUD_TOKEN in order to make a release, please contact @josegonzalez to get this information. + +## Changelog format + +The `HISTORY.md` should be added to based on the changes made since the previous release. This can be done by reviewing all merged pull requests to the master branch on github. The format is as follows: + +``` +## 0.9.9 + +Some description concerning major changes in this release, or potential incompatibilities. + +### New Features + +- #SOME_ID: @pull-request-creator Description + +### Bug Fixes + +- #SOME_ID: @pull-request-creator Description + +### Docs Changes + +- #SOME_ID: @pull-request-creator Description +``` diff --git a/docs/index.md b/docs/index.md index 8ecec63ef..851a2fc6f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -30,6 +30,7 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. - [Plugin Creation](http://progrium.viewdocs.io/dokku/development/plugin-creation) - [Pluginhooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) - [Test Suite](http://progrium.viewdocs.io/dokku/development/testing) +- [Release Process](http://progrium.viewdocs.io/dokku/development/release-process) ## Things this project won't do