refactor: only extract the nginx.conf.sigil from the source code and not an app path
The previous method was a bit more difficult for users to interact with as they needed to ensure the file was at a certain path in the built image. This change divorces the file from the built artifact, better aligning the nginx.conf.sigil handling with the rest of Dokku's monorepo support. A side effect of this is now building proxy configurations does not require access to the built image. Closes #5207
This commit is contained in:
@@ -50,6 +50,9 @@ cmd-nginx-report-single() {
|
||||
"--nginx-hsts-include-subdomains: $(fn-plugin-property-get-default "nginx" "$APP" "hsts-include-subdomains" "true")"
|
||||
"--nginx-hsts-max-age: $(fn-plugin-property-get-default "nginx" "$APP" "hsts-max-age" "15724800")"
|
||||
"--nginx-hsts-preload: $(fn-plugin-property-get-default "nginx" "$APP" "hsts-preload" "false")"
|
||||
"--nginx-computed-nginx-conf-sigil-path: $(fn-nginx-computed-nginx-conf-sigil-path "$APP")"
|
||||
"--nginx-global-nginx-conf-sigil-path: $(fn-nginx-global-nginx-conf-sigil-path)"
|
||||
"--nginx-nginx-conf-sigil-path: $(fn-nginx-nginx-conf-sigil-path "$APP")"
|
||||
"--nginx-proxy-buffer-size: $(fn-nginx-proxy-buffer-size "$APP")"
|
||||
"--nginx-proxy-buffering: $(fn-nginx-proxy-buffering "$APP")"
|
||||
"--nginx-proxy-buffers: $(fn-nginx-proxy-buffers "$APP")"
|
||||
|
||||
@@ -18,6 +18,9 @@ trigger-nginx-vhosts-core-post-deploy() {
|
||||
if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then
|
||||
plugn trigger domains-setup "$APP"
|
||||
nginx_build_config "$APP"
|
||||
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/upcoming.nginx.conf.sigil" ]]; then
|
||||
mv "${DOKKU_LIB_ROOT}/data/nginx-vhosts/upcoming.nginx.conf.sigil" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.conf.sigil"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
28
plugins/nginx-vhosts/core-post-extract
Executable file
28
plugins/nginx-vhosts/core-post-extract
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
trigger-nginx-vhosts-core-post-extract() {
|
||||
declare desc="nginx-vhosts post-extract plugin trigger"
|
||||
declare trigger="post-extract"
|
||||
declare APP="$1" SOURCECODE_WORK_DIR="$2"
|
||||
local CONF_SIGIL_PATH="$(fn-nginx-computed-nginx-conf-sigil-path "$APP")"
|
||||
|
||||
pushd "$TMP_WORK_DIR" >/dev/null
|
||||
|
||||
if [[ -z "$CONF_SIGIL_PATH" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -f "$CONF_SIGIL_PATH" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
rm -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/upcoming.nginx.conf.sigil"
|
||||
cp -f "$CONF_SIGIL_PATH" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/upcoming.nginx.conf.sigil"
|
||||
popd &>/dev/null || pushd "/tmp" >/dev/null
|
||||
}
|
||||
|
||||
trigger-nginx-vhosts-core-post-extract "$@"
|
||||
@@ -190,7 +190,11 @@ get_custom_nginx_template() {
|
||||
return
|
||||
fi
|
||||
|
||||
copy_from_image "$IMAGE" "$NGINX_TEMPLATE_NAME" "$DESTINATION_FILE" 2>/dev/null || true
|
||||
if [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/upcoming.nginx.conf.sigil" ]]; then
|
||||
cp "${DOKKU_LIB_ROOT}/data/nginx-vhosts/upcoming.nginx.conf.sigil" "$DESTINATION_FILE"
|
||||
elif [[ -f "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.conf.sigil" ]]; then
|
||||
cp "${DOKKU_LIB_ROOT}/data/nginx-vhosts/nginx.conf.sigil" "$DESTINATION_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
is_tls13_available() {
|
||||
|
||||
@@ -24,6 +24,28 @@ fn-nginx-hsts-is-enabled() {
|
||||
echo "$hsts_is_enabled"
|
||||
}
|
||||
|
||||
fn-nginx-computed-nginx-conf-sigil-path() {
|
||||
declare APP="$1"
|
||||
local conf_sigil_path="$(fn-nginx-nginx-conf-sigil-path "$APP")"
|
||||
|
||||
if [[ "$conf_sigil_path" == "" ]]; then
|
||||
conf_sigil_path="$(fn-nginx-global-nginx-conf-sigil-path)"
|
||||
fi
|
||||
|
||||
echo "$conf_sigil_path"
|
||||
}
|
||||
|
||||
fn-nginx-global-nginx-conf-sigil-path() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "--global" "nginx-conf-sigil-path" "nginx.conf.sigil"
|
||||
}
|
||||
|
||||
fn-nginx-nginx-conf-sigil-path() {
|
||||
declare APP="$1"
|
||||
fn-plugin-property-get-default "nginx" "$APP" "nginx-conf-sigil-path" ""
|
||||
}
|
||||
|
||||
fn-nginx-vhosts-manage-hsts() {
|
||||
declare APP="$1" SSL_ENABLED="$2"
|
||||
local HSTS="$(fn-nginx-hsts-is-enabled "$APP")"
|
||||
|
||||
@@ -9,13 +9,13 @@ cmd-nginx-set() {
|
||||
declare cmd="nginx:set"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "client-max-body-size" "disable-custom-config" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "proxy-read-timeout" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
|
||||
local VALID_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "client-max-body-size" "disable-custom-config" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "nginx-conf-sigil-path" "proxy-read-timeout" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
|
||||
local GLOBAL_KEYS=("hsts")
|
||||
|
||||
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||
|
||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||
dokku_log_fail "Invalid key specified, valid keys include: access-log-format, access-log-path, bind-address-ipv4, bind-address-ipv6, client-max-body-size, disable-custom-config, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, proxy-read-timeout, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, x-forwarded-for-value, x-forwarded-port-value, x-forwarded-proto-value, x-forwarded-ssl"
|
||||
dokku_log_fail "Invalid key specified, valid keys include: access-log-format, access-log-path, bind-address-ipv4, bind-address-ipv6, client-max-body-size, disable-custom-config, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, nginx-conf-sigil-path, proxy-read-timeout, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, x-forwarded-for-value, x-forwarded-port-value, x-forwarded-proto-value, x-forwarded-ssl"
|
||||
fi
|
||||
|
||||
if ! fn-in-array "$KEY" "${GLOBAL_KEYS[@]}"; then
|
||||
|
||||
Reference in New Issue
Block a user