Merge branch 'master' into apps_report_subcommand

This commit is contained in:
Jose Diaz-Gonzalez
2017-02-20 13:55:37 -07:00
committed by GitHub
103 changed files with 1088 additions and 486 deletions

View File

@@ -42,7 +42,7 @@ execute_script() {
COMMAND+=" rm -rf /tmp/cache ; "
COMMAND+=" ln -sf /cache /tmp/cache ; "
COMMAND+=" fi ; "
COMMAND+=" $SCRIPT_CMD ;"
COMMAND+=" $SCRIPT_CMD || exit 1;"
COMMAND+=" if [[ -d '/cache' ]]; then "
COMMAND+=" echo removing installation cache... ; "
COMMAND+=" rm -f /tmp/cache ; "

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core standard plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core events logging plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -8,6 +8,7 @@ case "$1" in
declare desc="return apps plugin help content"
cat<<help_content
apps, List your apps
apps:clone <old-app> <new-app>, Clones an app
apps:create <app>, Create a new app
apps:destroy <app>, Permanently destroy an app
apps:rename <old-app> <new-app>, Rename an app

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core apps plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

39
plugins/apps/subcommands/clone Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
apps_clone_cmd() {
declare desc="clones an app"
declare OLD_APP="$2" NEW_APP="$3"
local cmd="apps:clone"
local SKIP_REBUILD=false
if [[ "$2" == "--skip-deploy" ]]; then
SKIP_REBUILD=true
OLD_APP="$3"
NEW_APP="$4"
fi
[[ -z "$OLD_APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$NEW_APP" ]] && dokku_log_fail "Name is already taken"
local NEW_CACHE_DIR="$DOKKU_ROOT/$NEW_APP/cache"
apps_create "$NEW_APP"
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
if [[ -d "$NEW_CACHE_DIR" ]] && ! rmdir "$NEW_CACHE_DIR"; then
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$NEW_CACHE_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
fi
rm -rf "$NEW_CACHE_DIR"
[[ -f "$DOKKU_ROOT/$NEW_APP/URLS" ]] && sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/URLS"
[[ -f "$DOKKU_ROOT/$NEW_APP/VHOST" ]] && sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/VHOST"
[[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]] && sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive"
[[ "$SKIP_REBUILD" == "true" ]] || ps_rebuild "$NEW_APP"
plugn trigger post-app-clone "$OLD_APP" "$NEW_APP"
echo "Cloning $OLD_APP to $NEW_APP... done"
}
apps_clone_cmd "$@"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core build-env plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -2,6 +2,39 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
certs_info_cmd() {
# This is here because it's used in both the info and the default
declare desc="prints SSL certificate info for app"
local cmd="certs:info"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"; local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
if [[ -n "$APP_SSL_PATH" ]]; then
dokku_log_info1 "Fetching SSL Endpoint info for $APP..."
dokku_log_info1 "Certificate details:"
dokku_log_info2 "Common Name(s): "
for domain in $(get_ssl_hostnames "$APP" | xargs); do
dokku_log_info2 " $domain"
done
dokku_log_info2 "Expires At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not After :" | awk -F " : " '{ print $2 }')"
dokku_log_info2 "Issuer: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g")"
dokku_log_info2 "Starts At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not Before:" | awk -F ": " '{ print $2 }')"
dokku_log_info2 "Subject: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -subject | sed -e "s:subject= ::g"| sed -e "s:^/::g" | sed -e "s:/:; :g")"
local SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)"
if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then
local SSL_SELF_SIGNED="verified by a certificate authority."
else
local SSL_SELF_SIGNED="self signed."
fi
dokku_log_info2 "SSL certificate is $SSL_SELF_SIGNED"
else
dokku_log_info1 "$APP does not have an SSL endpoint"
fi
}
is_ssl_enabled() {
declare desc="returns 0 if ssl is enabled for given app"
local APP=$1; verify_app_name "$APP"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core certificate management plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -72,7 +72,6 @@ certs_set() {
cp "$KEY_FILE" "$APP_SSL_PATH/server.key"
chmod 750 "$APP_SSL_PATH"
chmod 640 "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.key"
cd "$DOKKU_ROOT"
plugn trigger post-certs-update "$APP"
plugn trigger post-domains-update "$APP"
}

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
certs_main_cmd() {
declare desc="an alias for certs:info"
local cmd="certs"
certs_info_cmd "$@"
}
certs_main_cmd "$@"

View File

@@ -22,14 +22,15 @@ certs_generate_cmd() {
mkdir -p "$APP_SSL_PATH"
dokku_log_info1 "Installing certificate and key..."
mv -f "$CERTS_GENERATE_TMP_WORK_DIR/server.key" "$CERTS_GENERATE_TMP_WORK_DIR/server.crt" "$APP_SSL_PATH"
mv -f "$CERTS_GENERATE_TMP_WORK_DIR/server.crt" "$CERTS_GENERATE_TMP_WORK_DIR/server.csr" "$CERTS_GENERATE_TMP_WORK_DIR/server.key" "$APP_SSL_PATH"
chmod 750 "$APP_SSL_PATH"
chmod 640 "$APP_SSL_PATH/server.key" "$APP_SSL_PATH/server.crt"
chmod 640 "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.csr" "$APP_SSL_PATH/server.key"
plugn trigger post-certs-update "$APP"
[[ -n "$DOMAIN" ]] && (domains_add "$APP" "$DOMAIN" || plugn trigger post-domains-update "$APP")
dokku_log_info1 "The following is a certificate signing request that can be used"
dokku_log_info1 "to generate an 'officially' signed SSL certificate for $APP at $DOMAIN"
dokku_log_info1 "by a CA of your choosing."
cat server.csr
cat "$APP_SSL_PATH/server.csr"
else
dokku_log_info1 "$APP has an SSL endpoint already defined"
fi

View File

@@ -3,36 +3,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
certs_info_cmd() {
declare desc="prints SSL certificate info for app"
local cmd="certs:info"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"; local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
if [[ -n "$APP_SSL_PATH" ]]; then
dokku_log_info1 "Fetching SSL Endpoint info for $APP..."
dokku_log_info1 "Certificate details:"
dokku_log_info2 "Common Name(s): "
for domain in $(get_ssl_hostnames "$APP" | xargs); do
dokku_log_info2 " $domain"
done
dokku_log_info2 "Expires At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not After :" | awk -F " : " '{ print $2 }')"
dokku_log_info2 "Issuer: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g")"
dokku_log_info2 "Starts At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not Before:" | awk -F ": " '{ print $2 }')"
dokku_log_info2 "Subject: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -subject | sed -e "s:subject= ::g"| sed -e "s:^/::g" | sed -e "s:/:; :g")"
local SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)"
if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then
local SSL_SELF_SIGNED="verified by a certificate authority."
else
local SSL_SELF_SIGNED="self signed."
fi
dokku_log_info2 "SSL certificate is $SSL_SELF_SIGNED"
else
dokku_log_info1 "$APP does not have an SSL endpoint"
fi
}
certs_info_cmd "$@"

View File

@@ -16,7 +16,7 @@ help_content
}
if [[ $1 = "checks:help" ]] ; then
echo -e 'Usage: dokku checks[:COMAND]'
echo -e 'Usage: dokku checks[:COMMAND]'
echo ''
echo 'Manage zero-downtime settings.'
echo ''

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core checks plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -251,7 +251,12 @@ parse_args() {
declare desc="top-level cli arg parser"
local next_index=1; local skip=false; local args=("$@")
for arg in "$@"; do
$skip && skip=false && continue
if [[ "$skip" == "true" ]]; then
next_index=$(( next_index + 1 ))
skip=false
continue
fi
case "$arg" in
--quiet)
export DOKKU_QUIET_OUTPUT=1
@@ -272,7 +277,7 @@ parse_args() {
export DOKKU_APP_NAME=${args[$next_index]}; skip=true
;;
esac
local next_index=$(( next_index + 1 ))
next_index=$(( next_index + 1 ))
done
return 0
}

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core common plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core config plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core docker-options plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -15,6 +15,8 @@ case "$1" in
domains:enable <app>, Enable VHOST support
domains:remove <app> <domain> [<domain> ...], Remove domains from app
domains:remove-global <domain> [<domain> ...], Remove global domain names
domains:set <app> <domain> [<domain> ...], Set domains for app
domains:set-global <domain> [<domain> ...], Set global domain names
help_content
}

View File

@@ -85,7 +85,7 @@ domains_add() {
fi
done
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
domains_enable "$APP" --no-restart
fi
@@ -98,6 +98,7 @@ domains_remove() {
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
shift 1
touch "$APP_VHOST_PATH"
for DOMAIN in "$@"; do
sed -i "\|^$DOMAIN\$|d" "$APP_VHOST_PATH"
dokku_log_info1 "Removed $DOMAIN from $APP"
@@ -105,12 +106,36 @@ domains_remove() {
plugn trigger post-domains-update "$APP" "remove" "$@"
}
domains_set() {
declare desc="set list of domains for app"
verify_app_name "$1"
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
shift 1
touch "$APP_VHOST_PATH"
for DOMAIN in "$@"; do
if ! (is_valid_hostname "$DOMAIN"); then
dokku_log_fail "$DOMAIN is invalid. exiting..."
fi
done
echo "$*" | tr " " "\n" > "$APP_VHOST_PATH"
dokku_log_info1 "Set $* for $APP"
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
domains_enable "$APP" --no-restart
fi
plugn trigger post-domains-update "$APP" "set" "$@"
}
domains_disable() {
declare desc="disable domains/VHOST support"
verify_app_name "$1"
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]];then
touch "$APP_VHOST_PATH"
if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]]; then
disable_app_vhost "$APP"
else
dokku_log_info1 "domains (VHOST) support is already disabled for app ($APP)"
@@ -123,7 +148,8 @@ domains_enable() {
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then
touch "$APP_VHOST_PATH"
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
if [[ -n "$DEFAULT_VHOSTS" ]]; then
echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH"
fi
@@ -138,6 +164,7 @@ domains_add_global() {
declare desc="add list of global domains"
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
touch "$GLOBAL_VHOST_PATH"
for DOMAIN in "$@"; do
if ! (is_valid_hostname "$DOMAIN"); then
dokku_log_fail "$DOMAIN is invalid. exiting..."
@@ -158,8 +185,24 @@ domains_remove_global() {
declare desc="remove list of domains"
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
touch "$GLOBAL_VHOST_PATH"
for DOMAIN in "$@"; do
sed -i "\|^$DOMAIN\$|d" "$GLOBAL_VHOST_PATH"
dokku_log_info1 "Removed $DOMAIN"
done
}
domains_set_global() {
declare desc="set list of global domains"
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
touch "$GLOBAL_VHOST_PATH"
for DOMAIN in "$@"; do
if ! (is_valid_hostname "$DOMAIN"); then
dokku_log_fail "$DOMAIN is invalid. exiting..."
fi
done
echo "$*" | tr " " "\n" > "$GLOBAL_VHOST_PATH"
dokku_log_info1 "Set $*"
}

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core domains plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -12,6 +12,11 @@ domains_main_cmd() {
dokku_log_info2_quiet "Global Domain Name"
get_global_vhosts
fi
if [[ "$APP" == "--global" ]]; then
return
fi
if [[ -n "$APP" ]]; then
verify_app_name "$APP"
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then

16
plugins/domains/subcommands/set Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_set_cmd() {
declare desc="set domains for app via command line"
local cmd="domains:set"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
shift 1
domains_set "$@"
}
domains_set_cmd "$@"

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_set_global_cmd() {
declare desc="set global domain names via command line"
local cmd="domains:set-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
shift 1
domains_set_global "$@"
}
domains_set_global_cmd "$@"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core enter plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -28,7 +28,7 @@ git_build_app_repo() {
git remote add origin "$DOKKU_ROOT/$APP" &> /dev/null
git fetch --depth=1 origin "refs/tags/$TMP_TAG" &> /dev/null
git reset --hard FETCH_HEAD &> /dev/null
git submodule update --init --recursive &> /dev/null
suppress_output git submodule update --init --recursive
GIT_DIR="$DOKKU_ROOT/$APP" git tag -d "$TMP_TAG" &> /dev/null || true
find -name .git -prune -exec rm -rf {} \; > /dev/null
@@ -41,16 +41,53 @@ git_build_app_repo() {
fi
}
suppress_output() {
declare desc="suppress all output from a given command unless there is an error"
local TMP_COMMAND_OUTPUT
TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX")
trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT
"$@" > "$TMP_COMMAND_OUTPUT" 2>&1 || {
local exit_code="$?"
cat "$TMP_COMMAND_OUTPUT"
return "$exit_code"
}
return 0
}
git_deploy_branch() {
declare desc="retrieve the deploy branch for a given application"
local cmd="git-hook"
local APP="$1"
local DOKKU_DEPLOY_BRANCH="$(config_get "$APP" DOKKU_DEPLOY_BRANCH || true)"
local DOKKU_GLOBAL_DEPLOY_BRANCH="$(config_get --global DOKKU_DEPLOY_BRANCH || true)"
if [[ -n "$DOKKU_DEPLOY_BRANCH" ]]; then
echo "$DOKKU_DEPLOY_BRANCH"
elif [[ -n "$DOKKU_GLOBAL_DEPLOY_BRANCH" ]]; then
echo "$DOKKU_GLOBAL_DEPLOY_BRANCH"
else
echo "master"
fi
}
git_hook_cmd() {
declare desc="kick off receive-app trigger from git prereceive hook"
local cmd="git-hook"
local APP="$2"
local APP="$2"
local DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
if ! git check-ref-format --branch "$DOKKU_DEPLOY_BRANCH" 2> /dev/null; then
echo $'\e[1G\e[K'"-----> WARNING: Invalid branch name '$DOKKU_DEPLOY_BRANCH' specified via DOKKU_DEPLOY_BRANCH."
echo $'\e[1G\e[K'"-----> For more details, please see the man page for 'git-check-ref-format.'"
return
fi
local oldrev newrev refname
while read -r oldrev newrev refname; do
# Only run this script for the master branch. You can remove this
# if block if you wish to run it for others as well.
if [[ $refname = "refs/heads/master" ]]; then
if [[ $refname = "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]]; then
# broken out into plugin so we might support other methods to receive an app
# shellcheck disable=SC2086
plugn trigger receive-app $APP $newrev

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core git plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core logs plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core named containers plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,26 +1,14 @@
#!/usr/bin/env bash
[[ " help nginx:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
case "$1" in
help | nginx:help)
help_content_func () {
declare desc="return nginx plugin help content"
cat<<help_content
nginx, Interact with Dokku's Nginx proxy
nginx:build-config <app>, (Re)builds nginx config for given app
nginx:access-logs <app> [-t], Show the nginx access logs for an application (-t follows)
nginx:error-logs <app> [-t], Show the nginx error logs for an application (-t follows)
help_content
}
if [[ $1 = "nginx:help" ]] ; then
echo -e 'Usage: dokku nginx[:COMMAND]'
echo ''
echo 'Interact with Dokku'"'"'s Nginx proxy.'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
help_formatted
else
help_content_func
fi

View File

@@ -6,6 +6,25 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
help_formatted (){
echo -e 'Usage: dokku nginx[:COMMAND]'
echo ''
echo 'Interact with Dokku'"'"'s Nginx proxy.'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
}
help_content_func () {
declare desc="return nginx plugin help content"
cat<<help_content
nginx, Interact with Dokku's Nginx proxy
nginx:build-config <app>, (Re)builds nginx config for given app
nginx:access-logs <app> [-t], Show the nginx access logs for an application (-t follows)
nginx:error-logs <app> [-t], Show the nginx error logs for an application (-t follows)
help_content
}
validate_nginx() {
declare desc="validate entire nginx config"
set +e
@@ -148,7 +167,7 @@ get_custom_nginx_template() {
}
is_spdy_enabled() {
declare desc="detects whether the installed nginx version has spdy or http2 support"
declare desc="detects whether the installed nginx version has spdy support"
local NGINX_VERSION="$1"
local MAJOR_VERSION MINOR_VERSION PATCH_VERSION
local HAS_SUPPORT=true
@@ -174,6 +193,33 @@ is_spdy_enabled() {
echo $HAS_SUPPORT
}
is_http2_enabled() {
declare desc="detects whether the installed nginx version has http2 support"
local NGINX_VERSION="$1"
local MAJOR_VERSION MINOR_VERSION PATCH_VERSION
local HAS_SUPPORT=false
if ! which nginx > /dev/null 2>&1; then
echo $HAS_SUPPORT
return
fi
MAJOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[1]}')
MINOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[2]}')
PATCH_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[3]}')
if [[ "$MAJOR_VERSION" -ge "2" ]]; then
HAS_SUPPORT=true
elif [[ "$MAJOR_VERSION" -eq "1" ]]; then
if [[ "$MINOR_VERSION" -eq "11" ]] && [[ "$PATCH_VERSION" -ge "5" ]]; then
HAS_SUPPORT=true
elif [[ "$MINOR_VERSION" -ge "12" ]]; then
HAS_SUPPORT=true
fi
fi
echo $HAS_SUPPORT
}
nginx_build_config() {
declare desc="build nginx config to proxy app containers using sigil"
local APP="$1"; verify_app_name "$APP"
@@ -245,11 +291,19 @@ nginx_build_config() {
else
local SSL_VHOSTS=$(< "$DOKKU_ROOT/HOSTNAME")
fi
local SSL_SERVER_NAME=$(echo "$SSL_VHOSTS" | xargs)
local SSL_SERVER_NAME
local host
for host in $SSL_VHOSTS; do
# SSL_SERVER_NAME should only contain items not in NOSSL_SERVER_NAME
if [[ ! $NOSSL_SERVER_NAME =~ (^|[[:space:]])$host($|[[:space:]]) ]]; then
SSL_SERVER_NAME="${host}${SSL_SERVER_NAME:+ $SSL_SERVER_NAME}"
fi
done
fi
local NGINX_VERSION="$(nginx -v 2>&1 | cut -d'/' -f 2)"
local SPDY_SUPPORTED="$(is_spdy_enabled "$NGINX_VERSION")"
local HTTP2_SUPPORTED="$(is_http2_enabled "$NGINX_VERSION")"
eval "$(config_export app "$APP")"
local SIGIL_PARAMS=(-f $NGINX_TEMPLATE APP="$APP" DOKKU_ROOT="$DOKKU_ROOT"
@@ -257,6 +311,7 @@ nginx_build_config() {
DOKKU_APP_LISTENERS="$DOKKU_APP_LISTENERS"
PASSED_LISTEN_IP_PORT="$PASSED_LISTEN_IP_PORT"
SPDY_SUPPORTED="$SPDY_SUPPORTED"
HTTP2_SUPPORTED="$HTTP2_SUPPORTED"
DOKKU_APP_LISTEN_PORT="$DOKKU_APP_LISTEN_PORT" DOKKU_APP_LISTEN_IP="$DOKKU_APP_LISTEN_IP"
APP_SSL_PATH="$APP_SSL_PATH" SSL_INUSE="$SSL_INUSE" SSL_SERVER_NAME="$SSL_SERVER_NAME"
NGINX_PORT="$NGINX_PORT" NGINX_SSL_PORT="$NGINX_SSL_PORT" RAW_TCP_PORTS="$RAW_TCP_PORTS"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core nginx-vhosts plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
nginx_main_cmd() {
declare desc="display nginx plugin help content"
local cmd="nginx"
help_formatted
}
nginx_main_cmd "$@"

View File

@@ -38,8 +38,8 @@ server {
}
{{ else if eq $scheme "https"}}
server {
listen [::]:{{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else }}http2{{ end }};
listen {{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else }}http2{{ end }};
listen [::]:{{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else if eq $.HTTP2_SUPPORTED "true" }}http2{{ end }};
listen {{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else if eq $.HTTP2_SUPPORTED "true" }}http2{{ end }};
{{ if $.SSL_SERVER_NAME }}server_name {{ $.SSL_SERVER_NAME }}; {{ end }}
{{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
access_log /var/log/nginx/{{ $.APP }}-access.log;

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core plugin plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core proxy plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core ps plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -7,11 +7,20 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions"
ps_restore_cmd() {
declare desc="starts all apps with DOKKU_APP_RESTORE not set to 0 via command line"
local cmd="ps:restore"
if which parallel > /dev/null 2>&1; then
dokku_apps | parallel dokku ps:start
return
fi
for app in $(dokku_apps); do
local DOKKU_APP_RESTORE=$(config_get "$app" DOKKU_APP_RESTORE || true)
if [[ $DOKKU_APP_RESTORE != 0 ]]; then
echo "Restoring app $app ..."
ps_start "$app"
if ps_start "$app"; then
continue
fi
dokku_log_warn "dokku ps:restore ${app} failed"
fi
done
}

View File

@@ -7,7 +7,7 @@ case "$1" in
help_content_func () {
declare desc="return repo plugin help content"
cat<<help_content
repo:gc <app>, Runs 'git gc --agressive' against the application's repo
repo:gc <app>, Runs 'git gc --aggressive' against the application's repo
repo:purge-cache <app>, Deletes the contents of the build cache stored in the repository
help_content
}

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core repo plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -3,7 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
repo_gc() {
declare desc="runs 'git gc --agressive' against the application's repo"
declare desc="runs 'git gc --aggressive' against the application's repo"
local cmd="repo:gc"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$2"; local APP_DIR="$DOKKU_ROOT/$APP"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core shell plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -2,6 +2,13 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
list_ssh_keys() {
declare desc="List ssh key hashes"
local cmd="ssh-keys:list"
verify_ssh_key_file
sshcommand list dokku
}
verify_ssh_key_file() {
declare desc="Test that public key is valid"
[[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
@@ -16,3 +23,8 @@ verify_ssh_key_exists() {
declare desc="Test that public key exists"
[[ -e ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
}
create_ssh_key_file() {
declare desc="Ensure the public key file exists"
touch "${DOKKU_ROOT}/.ssh/authorized_keys"
}

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core ssh-keys plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -19,6 +19,7 @@ add_keys() {
[[ -n "$name" && -n "$key_contents" ]] || dokku_log_fail "Two arguments are required if not piping, ie: dokku ssh-keys:add <NAME> <KEY_FILE>"
local count="$(wc -l <<< "$key_contents")"
[ "$count" -eq 1 ] || dokku_log_fail 'Too many keys provided, set one per invocation of dokku ssh-keys:add <NAME> <KEY_FILE>'
create_ssh_key_file
verify_ssh_key_exists
echo "$key_contents" | sshcommand acl-add dokku "$name" || dokku_log_fail "sshcommand returned an error: $?"
verify_ssh_key_file

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
ssh_keys_main_cmd() {
declare desc="an alias for ssh-keys:list"
local cmd="ssh-keys"
list_ssh_keys
}
ssh_keys_main_cmd "$@"

View File

@@ -3,11 +3,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
list_ssh_keys() {
declare desc="List ssh key hashes"
local cmd="ssh-keys:list"
verify_ssh_key_file
sshcommand list dokku
}
list_ssh_keys "$@"

View File

@@ -2,6 +2,16 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
storage_list_cmd() {
declare desc="List all bound mounts"
local cmd="storage:list"
local passed_phases="deploy"
[[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list."
verify_app_name "$2" && local APP="$2"
echo "$APP volume bind-mounts:"
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
}
verify_paths() {
declare desc="verifies storage paths"
echo "$1" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon."

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core storage plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
storage_main_cmd() {
declare desc="an alias for storage:list"
local cmd="storage"
storage_list_cmd "$@"
}
storage_main_cmd "$@"

View File

@@ -4,14 +4,5 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
storage_list_cmd() {
declare desc="List all bound mounts"
local cmd="storage:list"
local passed_phases="deploy"
[[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list."
verify_app_name "$2" && local APP="$2"
echo "$APP volume bind-mounts:"
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
}
storage_list_cmd "$@"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core tags plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]

View File

@@ -24,7 +24,7 @@ tar_build() {
tar -x -C "$TAR_BUILD_TMP_WORK_DIR" -f "$DOKKU_ROOT/$APP/src.tar" --strip-components="$BOGUS_PARTS"
chmod -R u+r "$TAR_BUILD_TMP_WORK_DIR"
if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then
if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]] && [[ -z $(config_get "$APP" BUILDPACK_URL || true) ]]; then
plugn trigger pre-receive-app "$APP" "dockerfile" "$TAR_BUILD_TMP_WORK_DIR"
dokku_receive "$APP" "dockerfile" "$TAR_BUILD_TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/"
else

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku core tar plugin"
version = "0.7.2"
version = "0.8.0"
[plugin.config]