Merge pull request #5488 from dokku/5435-potential-deploy-downtime
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
cmd-urls() {
|
||||
declare desc="reports dokku vitals for troubleshooting"
|
||||
declare cmd="url"
|
||||
declare APP="$2"
|
||||
declare URL_TYPE="$1" APP="$2"
|
||||
|
||||
verify_app_name "$APP"
|
||||
get_app_urls "$@"
|
||||
plugn trigger domains-urls "$APP" "$URL_TYPE"
|
||||
}
|
||||
|
||||
cmd-urls "$@"
|
||||
|
||||
1
plugins/20_events/builder-image-is-herokuish
Symbolic link
1
plugins/20_events/builder-image-is-herokuish
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/20_events/certs-exists
Symbolic link
1
plugins/20_events/certs-exists
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/20_events/domains-urls
Symbolic link
1
plugins/20_events/domains-urls
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
2
plugins/builder/.gitignore
vendored
2
plugins/builder/.gitignore
vendored
@@ -7,4 +7,4 @@
|
||||
/install
|
||||
/post-*
|
||||
/report
|
||||
/builder-detect
|
||||
/builder-*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SUBCOMMANDS = subcommands/report subcommands/set
|
||||
TRIGGERS = triggers/builder-detect triggers/core-post-extract triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report
|
||||
TRIGGERS = triggers/builder-detect triggers/builder-image-is-cnb triggers/builder-image-is-herokuish triggers/core-post-extract triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = builder
|
||||
|
||||
|
||||
@@ -21,6 +21,14 @@ func main() {
|
||||
case "builder-detect":
|
||||
appName := flag.Arg(0)
|
||||
err = builder.TriggerBuilderDetect(appName)
|
||||
case "builder-image-is-cnb":
|
||||
appName := flag.Arg(0)
|
||||
image := flag.Arg(1)
|
||||
err = builder.TriggerBuilderImageIsCNB(appName, image)
|
||||
case "builder-image-is-herokuish":
|
||||
appName := flag.Arg(0)
|
||||
image := flag.Arg(1)
|
||||
err = builder.TriggerBuilderImageIsHerokuish(appName, image)
|
||||
case "core-post-extract":
|
||||
appName := flag.Arg(0)
|
||||
sourceWorkDir := flag.Arg(1)
|
||||
|
||||
@@ -26,6 +26,28 @@ func TriggerBuilderDetect(appName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerBuilderImageIsCNB prints true if an image is cnb based, false otherwise
|
||||
func TriggerBuilderImageIsCNB(appName string, image string) error {
|
||||
if common.IsImageCnbBased(image) {
|
||||
fmt.Println("true")
|
||||
} else {
|
||||
fmt.Println("false")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerBuilderImageIsHerokuish prints true if an image is herokuish based, false otherwise
|
||||
func TriggerBuilderImageIsHerokuish(appName string, image string) error {
|
||||
if common.IsImageHerokuishBased(image, appName) {
|
||||
fmt.Println("true")
|
||||
} else {
|
||||
fmt.Println("false")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerCorePostExtract moves a configured build-dir to be in the app root dir
|
||||
func TriggerCorePostExtract(appName string, sourceWorkDir string) error {
|
||||
buildDir := strings.Trim(reportComputedBuildDir(appName), "/")
|
||||
|
||||
@@ -11,7 +11,6 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
|
||||
local app_domains caddy_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_port_map proxy_scheme proxy_schemes scheme tls_internal
|
||||
local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate
|
||||
local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate
|
||||
local app_urls_path="$DOKKU_ROOT/$APP/URLS"
|
||||
local STDIN=$(cat)
|
||||
|
||||
if [[ "$PROC_TYPE" != "web" ]]; then
|
||||
@@ -30,9 +29,6 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
|
||||
return
|
||||
fi
|
||||
|
||||
# run this silently or the output will be set as a label
|
||||
plugn trigger domains-setup "$APP" >/dev/null
|
||||
|
||||
# ensure we have a port mapping
|
||||
plugn trigger proxy-configure-ports "$APP"
|
||||
|
||||
@@ -131,9 +127,6 @@ trigger-caddy-vhosts-docker-args-process-deploy() {
|
||||
|
||||
output="$output --label \"caddy.reverse_proxy={{ upstreams $proxy_container_http_port }}\""
|
||||
fi
|
||||
|
||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
||||
xargs -I{} echo "$scheme://{}" <<<"$(echo "${app_domains}" | tr ' ' '\n' | sort -u)" >>"$app_urls_path"
|
||||
fi
|
||||
|
||||
echo -n "$STDIN$output"
|
||||
|
||||
18
plugins/certs/certs-exists
Executable file
18
plugins/certs/certs-exists
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
trigger-certs-certs-exists() {
|
||||
declare desc="checks if certs exist"
|
||||
declare trigger="certs-exists"
|
||||
declare APP="$1"
|
||||
|
||||
if is_ssl_enabled "$APP"; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
trigger-certs-certs-exists "$@"
|
||||
@@ -357,41 +357,18 @@ is_image_cnb_based() {
|
||||
declare desc="returns true if app image is based on cnb"
|
||||
declare IMAGE="$1"
|
||||
|
||||
if [[ -z "$IMAGE" ]]; then
|
||||
if [[ "$("$PLUGIN_CORE_AVAILABLE_PATH/common/common" --quiet image-is-cnb-based "$IMAGE")" != "true" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
CNB_STACK_ID="$("$DOCKER_BIN" image inspect --format '{{ index .Config.Labels "io.buildpacks.stack.id" }}' "$IMAGE")"
|
||||
if [[ -n "$CNB_STACK_ID" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
is_image_herokuish_based() {
|
||||
declare desc="returns true if app image is based on herokuish or a buildpack-like env"
|
||||
declare IMAGE="$1" APP="$2"
|
||||
local DOKKU_APP_USER
|
||||
local USER_VALUE
|
||||
|
||||
if [[ -z "$IMAGE" ]]; then
|
||||
if [[ "$("$PLUGIN_CORE_AVAILABLE_PATH/common/common" --quiet image-is-herokuish-based "$IMAGE" "$APP")" != "true" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if is_image_cnb_based "$IMAGE"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -n "$APP" ]]; then
|
||||
DOKKU_APP_USER=$(config_get "$APP" DOKKU_APP_USER || true)
|
||||
fi
|
||||
DOKKU_APP_USER=${DOKKU_APP_USER:="herokuishuser"}
|
||||
|
||||
# due to how the build process works, all herokuish images have the Environment variable USER=$DOKKU_APP_USER
|
||||
USER_VALUE="$("$DOCKER_BIN" image inspect --format '{{range .Config.Env}}{{if eq . "USER='"$DOKKU_APP_USER"'"}}{{println .}}{{end}}{{end}}' "$IMAGE")"
|
||||
[[ "$USER_VALUE" == "" ]] && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
get_docker_version() {
|
||||
@@ -719,7 +696,7 @@ release_and_deploy() {
|
||||
dokku_log_info1 "Deploying $APP via the $DOKKU_SCHEDULER scheduler..."
|
||||
cmd-deploy "$APP" "$IMAGE_TAG"
|
||||
dokku_log_info2 "Application deployed:"
|
||||
get_app_urls urls "$APP" | sed "s/^/ /"
|
||||
plugn trigger domains-urls "$APP" urls | sed "s/^/ /"
|
||||
else
|
||||
dokku_log_info1 "Skipping deployment"
|
||||
fi
|
||||
@@ -904,113 +881,6 @@ get_container_ports() {
|
||||
echo "$container_ports"
|
||||
}
|
||||
|
||||
get_app_urls() {
|
||||
declare desc="print an app's available urls"
|
||||
declare URL_TYPE="$1" APP="$2"
|
||||
local urls
|
||||
|
||||
urls=$(plugn trigger app-urls "$APP" "$URL_TYPE")
|
||||
if [[ -n "$urls" ]]; then
|
||||
echo "$urls" | sort
|
||||
else
|
||||
internal_get_app_urls "$URL_TYPE" "$APP" | sort
|
||||
fi
|
||||
}
|
||||
|
||||
internal_get_app_urls() {
|
||||
declare desc="print an app's available urls"
|
||||
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
local APP="$2"
|
||||
local URLS_FILE="$DOKKU_ROOT/$APP/URLS"
|
||||
local DOKKU_PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)
|
||||
|
||||
if [[ -s "$URLS_FILE" ]]; then
|
||||
local app_urls="$(grep -v -E "^#" "$URLS_FILE")"
|
||||
if [[ -n "$DOKKU_PROXY_PORT_MAP" ]]; then
|
||||
local port_map app_vhost
|
||||
local app_vhosts=$(plugn trigger domains-list "$APP")
|
||||
for port_map in $DOKKU_PROXY_PORT_MAP; do
|
||||
local scheme="$(awk -F ':' '{ print $1 }' <<<"$port_map")"
|
||||
local listen_port="$(awk -F ':' '{ print $2 }' <<<"$port_map")"
|
||||
for app_vhost in $app_vhosts; do
|
||||
if [[ "$listen_port" != "80" ]] && [[ "$listen_port" != "443" ]]; then
|
||||
port_urls+=" $scheme://$app_vhost:$listen_port "
|
||||
else
|
||||
port_urls+=" $scheme://$app_vhost "
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
local port_urls="$(echo "$port_urls" | xargs)"
|
||||
local URLS="$(merge_dedupe_list "$port_urls $app_urls" " ")"
|
||||
case "$1" in
|
||||
url)
|
||||
if is_ssl_enabled "$APP"; then
|
||||
echo "$URLS" | tr ' ' '\n' | grep https | head -n1
|
||||
else
|
||||
echo "$URLS" | tr ' ' '\n' | head -n1
|
||||
fi
|
||||
;;
|
||||
urls)
|
||||
echo "$URLS" | tr ' ' '\n' | sort
|
||||
;;
|
||||
esac
|
||||
else
|
||||
if [[ -s "$DOKKU_ROOT/VHOST" ]]; then
|
||||
while read -r VHOST || [[ -n "$VHOST" ]]; do
|
||||
internal_get_app_url_with_vhost "$APP" "$VHOST"
|
||||
done <"$DOKKU_ROOT/VHOST"
|
||||
else
|
||||
internal_get_app_url_with_vhost "$APP" "$(hostname -f)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
internal_get_app_url_with_vhost() {
|
||||
declare APP="$1" VHOST="$2"
|
||||
|
||||
local RAW_TCP_PORTS="$(get_app_raw_tcp_ports "$APP")"
|
||||
local DOKKU_PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)
|
||||
local SCHEME="http"
|
||||
local SSL="$DOKKU_ROOT/$APP/tls"
|
||||
if [[ -e "$SSL/server.crt" && -e "$SSL/server.key" ]]; then
|
||||
local SCHEME="https"
|
||||
fi
|
||||
|
||||
if [[ "$(plugn trigger proxy-is-enabled "$APP")" == "false" ]]; then
|
||||
if [[ -n "$RAW_TCP_PORTS" ]]; then
|
||||
local APP_CONTAINER_PORTS="$(get_container_ports "$APP")"
|
||||
local app_port
|
||||
for app_port in $APP_CONTAINER_PORTS; do
|
||||
echo "$VHOST:$app_port (container)"
|
||||
done
|
||||
else
|
||||
local DOKKU_APP_WEB_LISTENERS PORT
|
||||
DOKKU_APP_WEB_LISTENERS="$(plugn trigger network-get-listeners "$APP" "web" | xargs)"
|
||||
for DOKKU_APP_WEB_LISTENER in $DOKKU_APP_WEB_LISTENERS; do
|
||||
PORT="$(echo "$DOKKU_APP_WEB_LISTENER" | cut -d ':' -f2)"
|
||||
echo "$SCHEME://$VHOST:$PORT (container)"
|
||||
done
|
||||
shopt -u nullglob
|
||||
fi
|
||||
elif [[ -n "$DOKKU_PROXY_PORT_MAP" ]]; then
|
||||
local port_map
|
||||
for port_map in $DOKKU_PROXY_PORT_MAP; do
|
||||
local scheme="$(awk -F ':' '{ print $1 }' <<<"$port_map")"
|
||||
local listen_port="$(awk -F ':' '{ print $2 }' <<<"$port_map")"
|
||||
echo "$scheme://$VHOST:$listen_port"
|
||||
done
|
||||
elif [[ -n "$RAW_TCP_PORTS" ]]; then
|
||||
for p in $RAW_TCP_PORTS; do
|
||||
echo "http://$VHOST:$p"
|
||||
done
|
||||
else
|
||||
echo "$SCHEME://$VHOST"
|
||||
fi
|
||||
}
|
||||
|
||||
get_json_value() {
|
||||
declare desc="return value of provided json key from a json stream on stdin"
|
||||
# JSON_NODE should be expresses as either a top-level object that has no children
|
||||
|
||||
@@ -32,6 +32,21 @@ func main() {
|
||||
if !common.IsDeployed(appName) {
|
||||
err = fmt.Errorf("App %v not deployed", appName)
|
||||
}
|
||||
case "image-is-cnb-based":
|
||||
image := flag.Arg(1)
|
||||
if common.IsImageCnbBased(image) {
|
||||
fmt.Print("true")
|
||||
} else {
|
||||
fmt.Print("false")
|
||||
}
|
||||
case "image-is-herokuish-based":
|
||||
image := flag.Arg(1)
|
||||
appName := flag.Arg(2)
|
||||
if common.IsImageHerokuishBased(image, appName) {
|
||||
fmt.Print("true")
|
||||
} else {
|
||||
fmt.Print("false")
|
||||
}
|
||||
case "scheduler-detect":
|
||||
appName := flag.Arg(1)
|
||||
if *global {
|
||||
|
||||
35
plugins/domains/domains-urls
Executable file
35
plugins/domains/domains-urls
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
trigger-domains-domains-urls() {
|
||||
declare desc="gets an app's urls"
|
||||
declare trigger="domains-urls"
|
||||
declare APP="$1" URL_TYPE="$2"
|
||||
local urls
|
||||
|
||||
local SCHEME="http"
|
||||
local DEFAULT_LISTEN_PORT="80"
|
||||
if [[ "$(plugn trigger certs-exists "$APP")" == "true" ]]; then
|
||||
SCHEME="https"
|
||||
DEFAULT_LISTEN_PORT="443"
|
||||
fi
|
||||
|
||||
urls=$(plugn trigger app-urls "$APP" "$URL_TYPE")
|
||||
if [[ -n "$urls" ]]; then
|
||||
if [[ "$URL_TYPE" == "url" ]]; then
|
||||
echo "$urls" | tr ' ' '\n' | grep "$SCHEME://" | head -n1
|
||||
else
|
||||
echo "$urls" | tr ' ' '\n' | sort
|
||||
fi
|
||||
else
|
||||
if [[ "$URL_TYPE" == "url" ]]; then
|
||||
fn-domains-generate-urls "$APP" "$SCHEME" "$DEFAULT_LISTEN_PORT" | tr ' ' '\n' | grep "$SCHEME://" | head -n1
|
||||
else
|
||||
fn-domains-generate-urls "$APP" "$SCHEME" "$DEFAULT_LISTEN_PORT" | tr ' ' '\n' | sort
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
trigger-domains-domains-urls "$@"
|
||||
@@ -8,12 +8,11 @@ disable_app_vhost() {
|
||||
declare desc="disable vhost support for given application"
|
||||
declare APP=$1 RESTART_APP="$2"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP_URLS_PATH="$DOKKU_ROOT/$APP/URLS"
|
||||
|
||||
plugn trigger pre-disable-vhost "$APP"
|
||||
if [[ -f "$APP_VHOST_PATH" ]] || [[ -f "$APP_URLS_PATH" ]]; then
|
||||
if [[ -f "$APP_VHOST_PATH" ]]; then
|
||||
dokku_log_info1 "App virtual host support disabled"
|
||||
rm -f "$APP_VHOST_PATH" "$APP_URLS_PATH"
|
||||
rm -f "$APP_VHOST_PATH"
|
||||
fi
|
||||
|
||||
[[ "$RESTART_APP" == "--no-restart" ]] && local CONFIG_SET_ARGS=$RESTART_APP
|
||||
|
||||
@@ -10,6 +10,7 @@ trigger-domains-install() {
|
||||
shopt -s nullglob
|
||||
for app in $(dokku_apps "false" 2>/dev/null); do
|
||||
domains_setup "$app"
|
||||
rm -f "$DOKKU_ROOT/$APP/URLS"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
@@ -114,3 +114,70 @@ fn-domains-global-vhosts() {
|
||||
get_global_vhosts | tr '\n' ' '
|
||||
fi
|
||||
}
|
||||
|
||||
fn-domains-generate-urls() {
|
||||
declare APP="$1" SCHEME="$2" DEFAULT_LISTEN_PORT="$3"
|
||||
|
||||
local app_vhosts="$(plugn trigger domains-list "$APP")"
|
||||
if [[ -n "$app_vhosts" ]]; then
|
||||
for app_vhost in $app_vhosts; do
|
||||
fn-domains-generate-urls-from-config "$APP" "$SCHEME" "$app_vhost" "$DEFAULT_LISTEN_PORT"
|
||||
done
|
||||
else
|
||||
if [[ -s "$DOKKU_ROOT/VHOST" ]]; then
|
||||
while read -r VHOST || [[ -n "$VHOST" ]]; do
|
||||
fn-domains-generate-urls-from-config "$APP" "$SCHEME" "$VHOST" "$DEFAULT_LISTEN_PORT"
|
||||
done <"$DOKKU_ROOT/VHOST"
|
||||
else
|
||||
fn-domains-generate-urls-from-config "$APP" "$SCHEME" "$(hostname -f)" "$DEFAULT_LISTEN_PORT"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
fn-domains-generate-urls-from-config() {
|
||||
declare APP="$1" SCHEME="$2" VHOST="$3" DEFAULT_LISTEN_PORT="$4"
|
||||
local DOKKU_PROXY_PORT_MAP=$(plugn trigger config-get "$APP" DOKKU_PROXY_PORT_MAP || true)
|
||||
local RAW_TCP_PORTS="$(get_app_raw_tcp_ports "$APP")"
|
||||
|
||||
if [[ "$(plugn trigger proxy-is-enabled "$APP")" == "false" ]]; then
|
||||
if [[ -n "$RAW_TCP_PORTS" ]]; then
|
||||
local APP_CONTAINER_PORTS="$(get_container_ports "$APP")"
|
||||
local app_port
|
||||
for listen_port in $APP_CONTAINER_PORTS; do
|
||||
fn-domains-generate-url "$SCHEME" "$VHOST" "$listen_port"
|
||||
done
|
||||
else
|
||||
local DOKKU_APP_WEB_LISTENERS PORT
|
||||
DOKKU_APP_WEB_LISTENERS="$(plugn trigger network-get-listeners "$APP" "web" | xargs)"
|
||||
for DOKKU_APP_WEB_LISTENER in $DOKKU_APP_WEB_LISTENERS; do
|
||||
listen_port="$(echo "$DOKKU_APP_WEB_LISTENER" | cut -d ':' -f2)"
|
||||
fn-domains-generate-url "$SCHEME" "$VHOST" "$listen_port"
|
||||
done
|
||||
shopt -u nullglob
|
||||
fi
|
||||
elif [[ -n "$DOKKU_PROXY_PORT_MAP" ]]; then
|
||||
local port_map
|
||||
for port_map in $DOKKU_PROXY_PORT_MAP; do
|
||||
local scheme="$(awk -F ':' '{ print $1 }' <<<"$port_map")"
|
||||
local listen_port="$(awk -F ':' '{ print $2 }' <<<"$port_map")"
|
||||
fn-domains-generate-url "$SCHEME" "$VHOST" "$listen_port"
|
||||
done
|
||||
elif [[ -n "$RAW_TCP_PORTS" ]]; then
|
||||
for listen_port in $RAW_TCP_PORTS; do
|
||||
fn-domains-generate-url "$SCHEME" "$VHOST" "$listen_port"
|
||||
done
|
||||
else
|
||||
fn-domains-generate-url "$SCHEME" "$VHOST" "$DEFAULT_LISTEN_PORT"
|
||||
fi
|
||||
}
|
||||
|
||||
fn-domains-generate-url() {
|
||||
declare SCHEME="$1" VHOST="$2" PORT="$3"
|
||||
if [[ "$PORT" == "80" ]]; then
|
||||
echo "http://$VHOST"
|
||||
elif [[ "$PORT" == "443" ]]; then
|
||||
echo "https://$VHOST"
|
||||
else
|
||||
echo "$SCHEME://$VHOST:$PORT"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ trigger-domains-post-app-clone-setup() {
|
||||
declare OLD_APP="$1" NEW_APP="$2"
|
||||
local APP_ROOT="$DOKKU_ROOT/$NEW_APP"
|
||||
|
||||
rm -rf "$APP_ROOT/URLS" "$APP_ROOT/VHOST"
|
||||
rm -rf "$APP_ROOT/VHOST"
|
||||
}
|
||||
|
||||
trigger-domains-post-app-clone-setup "$@"
|
||||
|
||||
@@ -3,12 +3,10 @@ set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
trigger-domains-post-app-rename-setup() {
|
||||
declare desc="updates VHOST and URLS files during rename"
|
||||
declare desc="updates VHOST files during rename"
|
||||
declare trigger="post-app-rename-setup"
|
||||
declare OLD_APP="$1" NEW_APP="$2"
|
||||
|
||||
rm -f "$DOKKU_ROOT/$NEW_APP/URLS"
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/$NEW_APP/VHOST" ]]; then
|
||||
while read -r VHOST || [[ -n "$VHOST" ]]; do
|
||||
sed -i -e "s/$OLD_APP.$VHOST/$NEW_APP.$VHOST/g" "$DOKKU_ROOT/$NEW_APP/VHOST"
|
||||
|
||||
@@ -3,17 +3,17 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
trigger-domains-domains-setup() {
|
||||
trigger-domains-post-create() {
|
||||
declare desc="creates vhost files as necessary"
|
||||
declare trigger="domains-setup"
|
||||
declare trigger="post-create"
|
||||
declare APP="$1"
|
||||
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
|
||||
dokku_log_info1 "App virtual host support disabled, skipping domains setup"
|
||||
dokku_log_info1 "App virtual host support disabled, skipping domain setup"
|
||||
return
|
||||
fi
|
||||
|
||||
domains_setup "$APP"
|
||||
}
|
||||
|
||||
trigger-domains-domains-setup "$@"
|
||||
trigger-domains-post-create "$@"
|
||||
@@ -61,6 +61,10 @@ func BuildConfig(appName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if common.GetAppScheduler(appName) != "docker-local" {
|
||||
return nil
|
||||
}
|
||||
|
||||
image := common.GetAppImageName(appName, "", "")
|
||||
isHerokuishContainer := common.IsImageHerokuishBased(image, appName)
|
||||
common.LogInfo1(fmt.Sprintf("Ensuring network configuration is in sync for %s", appName))
|
||||
@@ -221,7 +225,11 @@ func HasNetworkConfig(appName string) bool {
|
||||
ipfile := fmt.Sprintf("%v/IP.web.1", appRoot)
|
||||
portfile := fmt.Sprintf("%v/PORT.web.1", appRoot)
|
||||
|
||||
return common.FileExists(ipfile) && common.FileExists(portfile)
|
||||
if common.FileExists(ipfile) && common.FileExists(portfile) {
|
||||
return true
|
||||
}
|
||||
|
||||
return reportStaticWebListener(appName) != ""
|
||||
}
|
||||
|
||||
// ClearNetworkConfig removes old IP and PORT files for a newly cloned app
|
||||
|
||||
@@ -14,20 +14,7 @@ trigger-nginx-vhosts-core-post-deploy() {
|
||||
return
|
||||
fi
|
||||
|
||||
HAS_NETWORK_CONFIG="$(plugn trigger network-config-exists "$APP")"
|
||||
if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then
|
||||
plugn trigger domains-setup "$APP"
|
||||
nginx_build_config "$APP"
|
||||
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" ]]; then
|
||||
mv "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil"
|
||||
fi
|
||||
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing" ]]; then
|
||||
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing"
|
||||
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil"
|
||||
fi
|
||||
else
|
||||
nginx_clear_config "$APP"
|
||||
fi
|
||||
plugn trigger proxy-build-config "$APP"
|
||||
}
|
||||
|
||||
trigger-nginx-vhosts-core-post-deploy "$@"
|
||||
|
||||
@@ -311,7 +311,6 @@ nginx_build_config() {
|
||||
declare desc="build nginx config to proxy app containers using sigil"
|
||||
declare APP="$1" DOKKU_APP_LISTEN_PORT="$2" DOKKU_APP_LISTEN_IP="$3"
|
||||
local VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP_URLS_PATH="$DOKKU_ROOT/$APP/URLS"
|
||||
local NGINX_TEMPLATE_NAME="nginx.conf.sigil"
|
||||
local NGINX_TEMPLATE="$PLUGIN_AVAILABLE_PATH/nginx-vhosts/templates/$NGINX_TEMPLATE_NAME"
|
||||
local SCHEME=http
|
||||
@@ -329,7 +328,7 @@ nginx_build_config() {
|
||||
plugn trigger domains-vhost-enabled "$APP" 2>/dev/null || IS_APP_VHOST_ENABLED=false
|
||||
|
||||
local IS_SSL_ENABLED=false
|
||||
if is_ssl_enabled "$APP"; then
|
||||
if [[ "$(plugn trigger certs-exists "$APP")" == "true" ]]; then
|
||||
IS_SSL_ENABLED=true
|
||||
fi
|
||||
|
||||
@@ -516,11 +515,6 @@ nginx_build_config() {
|
||||
dokku_log_verbose "Reloading nginx"
|
||||
validate_nginx && restart_nginx >/dev/null
|
||||
fi
|
||||
|
||||
if ([[ -n "$NONSSL_VHOSTS" ]] || [[ -n "$SSL_VHOSTS" ]]) && [[ "$IS_APP_VHOST_ENABLED" == "true" ]]; then
|
||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$APP_URLS_PATH"
|
||||
xargs -i echo "$SCHEME://{}" <<<"$(echo "${SSL_VHOSTS}" "${NONSSL_VHOSTS}" | tr ' ' '\n' | sort -u)" >>"$APP_URLS_PATH"
|
||||
fi
|
||||
else
|
||||
# note because this clause is long. if the proxy is disabled:
|
||||
dokku_log_info1 "Nginx support is disabled for app ($APP)"
|
||||
|
||||
@@ -8,11 +8,25 @@ trigger-nginx-vhosts-proxy-build-config() {
|
||||
declare desc="build nginx config to proxy app containers from command line"
|
||||
declare trigger="proxy-build-config"
|
||||
declare APP="$1"
|
||||
local HAS_NETWORK_CONFIG
|
||||
|
||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
HAS_NETWORK_CONFIG="$(plugn trigger network-config-exists "$APP")"
|
||||
if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then
|
||||
plugn trigger network-build-config "$APP"
|
||||
nginx_build_config "$APP"
|
||||
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" ]]; then
|
||||
mv "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil"
|
||||
fi
|
||||
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing" ]]; then
|
||||
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil.$DOKKU_PID.missing"
|
||||
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/app-$APP/nginx.conf.sigil"
|
||||
fi
|
||||
else
|
||||
nginx_clear_config "$APP"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
@@ -29,7 +28,7 @@ trigger-proxy-proxy-configure-ports() {
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_PROXY_PORT="$PROXY_PORT"
|
||||
fi
|
||||
if [[ -z "$DOKKU_PROXY_SSL_PORT" ]]; then
|
||||
if (is_ssl_enabled "$APP"); then
|
||||
if [[ "$(plugn trigger certs-exists "$APP")" == "true" ]]; then
|
||||
local PROXY_SSL_PORT=$(config_get --global DOKKU_PROXY_SSL_PORT)
|
||||
PROXY_SSL_PORT=${PROXY_SSL_PORT:=443}
|
||||
if [[ -z "$RAW_TCP_PORTS" ]] && [[ "$IS_APP_VHOST_ENABLED" == "false" ]]; then
|
||||
|
||||
@@ -11,7 +11,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
||||
local app_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_port_map priority proxy_scheme proxy_schemes traefik_domains
|
||||
local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate
|
||||
local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate
|
||||
local app_urls_path="$DOKKU_ROOT/$APP/URLS"
|
||||
local STDIN=$(cat)
|
||||
|
||||
if [[ "$PROC_TYPE" != "web" ]]; then
|
||||
@@ -30,9 +29,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
||||
return
|
||||
fi
|
||||
|
||||
# run this silently or the output will be set as a label
|
||||
plugn trigger domains-setup "$APP" >/dev/null
|
||||
|
||||
# ensure we have a port mapping
|
||||
plugn trigger proxy-configure-ports "$APP"
|
||||
|
||||
@@ -111,8 +107,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
||||
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.service=$APP-$PROC_TYPE-http"
|
||||
if [[ -n "$traefik_domains" ]]; then
|
||||
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-http.rule=Host(\\\`$traefik_domains\\\`)\""
|
||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
||||
xargs -I{} echo "http://{}" <<<"$(echo "${app_domains}" | tr ' ' '\n' | sort -u)" >>"$app_urls_path"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -130,8 +124,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
||||
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.tls.certresolver=leresolver"
|
||||
if [[ -n "$traefik_domains" ]]; then
|
||||
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-https.rule=Host(\\\`$traefik_domains\\\`)\""
|
||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
||||
xargs -I{} echo "https://{}" <<<"$(echo "${app_domains}" | tr ' ' '\n' | sort -u)" >>"$app_urls_path"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user