From 7c58559e27cad0aee230d1e9746ff77f589ffa44 Mon Sep 17 00:00:00 2001 From: Konstantin Demin Date: Wed, 17 Jul 2024 13:50:13 +0300 Subject: [PATCH] improve module handling --- Dockerfile | 3 --- angie/snip.dist/http-brotli-static.conf | 2 -- angie/snip.dist/http-gzip-static.conf | 2 -- angie/snip.dist/http-zstd-static.conf | 2 -- image-entry.d/00-common.envsh | 20 ++++++++++---------- image-entry.d/21-http-modules.envsh | 9 +++++++++ image-entry.d/54-combine-tree.sh | 20 +++++++++++++++++--- scripts/apt-install-angie-mod.sh | 6 +++--- 8 files changed, 39 insertions(+), 25 deletions(-) delete mode 100644 angie/snip.dist/http-brotli-static.conf delete mode 100644 angie/snip.dist/http-gzip-static.conf delete mode 100644 angie/snip.dist/http-zstd-static.conf diff --git a/Dockerfile b/Dockerfile index 1297270..7306f12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -172,15 +172,12 @@ RUN apt-install.sh \ ## relatively lightweight modules RUN apt-install-angie-mod.sh \ - auth-jwt \ - auth-spnego \ brotli \ cache-purge \ echo \ geoip2 \ headers-more \ subs \ - testcookie \ upload \ zip \ zstd \ diff --git a/angie/snip.dist/http-brotli-static.conf b/angie/snip.dist/http-brotli-static.conf deleted file mode 100644 index 0b7c7d9..0000000 --- a/angie/snip.dist/http-brotli-static.conf +++ /dev/null @@ -1,2 +0,0 @@ -## no extra configuration is present at this time -## ref: https://github.com/google/ngx_brotli/ diff --git a/angie/snip.dist/http-gzip-static.conf b/angie/snip.dist/http-gzip-static.conf deleted file mode 100644 index 5f33c12..0000000 --- a/angie/snip.dist/http-gzip-static.conf +++ /dev/null @@ -1,2 +0,0 @@ -## no extra configuration is present at this time -## ref: https://angie.software/en/configuration/modules/http_gzip_static/ diff --git a/angie/snip.dist/http-zstd-static.conf b/angie/snip.dist/http-zstd-static.conf deleted file mode 100644 index 730b785..0000000 --- a/angie/snip.dist/http-zstd-static.conf +++ /dev/null @@ -1,2 +0,0 @@ -## no extra configuration is present at this time -## ref: https://github.com/tokers/zstd-nginx-module/ diff --git a/image-entry.d/00-common.envsh b/image-entry.d/00-common.envsh index 1bbb682..7dea860 100644 --- a/image-entry.d/00-common.envsh +++ b/image-entry.d/00-common.envsh @@ -40,19 +40,19 @@ gobool_to_int() { IEP_TRACE=$(gobool_to_int "${IEP_TRACE:-0}" 0) export IEP_TRACE -if [ "${IEP_TRACE}" = 1 ] ; then - log_always() { echo "# $(date +'%Y-%m-%d %H:%M:%S.%03N %z'): ${__IEP_SRC}${*:+: $*}" >&2 ; } -else - log_always() { echo "# ${__IEP_SRC}${*:+: $*}" >&2 ; } -fi +log_always() { + if [ "${IEP_TRACE}" = 1 ] ; then + echo "# $(date +'%Y-%m-%d %H:%M:%S.%03N %z'): ${__IEP_SRC}${*:+: $*}" + else + echo "# ${__IEP_SRC}${*:+: $*}" + fi >&2 +} IEP_VERBOSE=$(gobool_to_int "${IEP_VERBOSE:-${IEP_TRACE}}" "${IEP_TRACE}") export IEP_VERBOSE -if [ "${IEP_VERBOSE}" = 1 ] ; then - log() { log_always "$@" ; } -else - log() { : ;} -fi +log() { + [ "${IEP_VERBOSE}" = 0 ] || log_always "$@" +} log_file() { sed -E '/^./s,^, ,' < "$1" >&2 ; } diff --git a/image-entry.d/21-http-modules.envsh b/image-entry.d/21-http-modules.envsh index 6854fb0..6e2f22e 100755 --- a/image-entry.d/21-http-modules.envsh +++ b/image-entry.d/21-http-modules.envsh @@ -5,6 +5,15 @@ if [ "${NGX_HTTP}" = 1 ] ; then http_modules= http_snippets="${NGX_HTTP_SNIPPETS:-}" + if [ -n "${NGX_HTTP_MODULES}" ] ; then + ## angie-module-lua: depends on angie-module-ndk + ## angie-module-set-misc: depends on angie-module-ndk + NGX_HTTP_MODULES=$( + printf '%s' "${NGX_HTTP_MODULES}" \ + | sed -zE 's/(\s|^)(lua|set-misc)(\s|$)/\1ndk \2\3/g' + ) + fi + ## filter out builtin http modules unset i for i in ${NGX_HTTP_MODULES:-} ; do diff --git a/image-entry.d/54-combine-tree.sh b/image-entry.d/54-combine-tree.sh index 26829d1..2f19513 100755 --- a/image-entry.d/54-combine-tree.sh +++ b/image-entry.d/54-combine-tree.sh @@ -21,15 +21,22 @@ rm -f "$t" ; unset t [ "${NGX_STRICT_LOAD}" = 0 ] || set -e +load_error_delim() { + IEP_TRACE=0 log_always ' ----------------------------------- ' +} load_error() { - [ "${load_error_seen:-}" = 1 ] || log_always 'tree combine has failed' + [ "${load_error_seen:-}" != 1 ] || return load_error_seen=1 + load_error_delim + log_always 'tree combine has failed' if [ "${NGX_STRICT_LOAD}" = 1 ] ; then t=10 log_always "injecting delay for $t seconds" + load_error_delim sleep $t exit 1 fi + load_error_delim } dirs='cache lib log' @@ -140,8 +147,10 @@ combine_snippets() { old_path="${old_dir}/${old_name}" if ! [ -f "${old_path}" ] ; then log_always "file ${old_name} is not found in ${old_dir}/" - load_error - log "file ${old_name} is skipped" + if [ "${NGX_ALLOW_MISSING_SNIPPETS:-}" != 1 ] ; then + load_error + log "file ${old_name} is skipped" + fi continue fi @@ -154,12 +163,17 @@ combine_modules http ${NGX_HTTP_MODULES:-} combine_modules mail ${NGX_MAIL_MODULES:-} combine_modules stream ${NGX_STREAM_MODULES:-} +unset NGX_ALLOW_MISSING_SNIPPETS + combine_snippets core ${NGX_CORE_SNIPPETS:-} combine_snippets core_ev ${NGX_CORE_EVENTS_SNIPPETS:-} combine_snippets http ${NGX_HTTP_SNIPPETS:-} combine_snippets mail ${NGX_MAIL_SNIPPETS:-} combine_snippets stream ${NGX_STREAM_SNIPPETS:-} +## some modules doesn't have configuration at all +NGX_ALLOW_MISSING_SNIPPETS=1 + combine_snippets core ${NGX_CORE_MODULES:-} combine_snippets http ${NGX_HTTP_MODULES:-} combine_snippets mail ${NGX_MAIL_MODULES:-} diff --git a/scripts/apt-install-angie-mod.sh b/scripts/apt-install-angie-mod.sh index 69381ba..46f05d3 100755 --- a/scripts/apt-install-angie-mod.sh +++ b/scripts/apt-install-angie-mod.sh @@ -48,8 +48,8 @@ gen_mod_config() { [ -n "$3" ] || return for __m in $3 ; do - echo "load_module ${__m};" >> "$2" - done + echo "load_module ${__m};" + done > "$2" } for i ; do @@ -87,7 +87,7 @@ for i ; do mail_modules= stream_modules= while read -r fmod ; do - fmod_short="modules.dist/${fmod#"${ANGIE_MODULES_DIR}/"}" + fmod_short="modules.d/${fmod#"${ANGIE_MODULES_DIR}/"}" fname=${fmod##*/} case "${fname}" in ngx_http_* )