diff --git a/angie/snip.dist/http-brotli.conf b/angie/snip.dist/http-brotli.conf deleted file mode 100644 index ff5bfde..0000000 --- a/angie/snip.dist/http-brotli.conf +++ /dev/null @@ -1,24 +0,0 @@ -## default is 6 -brotli_comp_level 5; -## default is 512k -brotli_window 64k; - -brotli_min_length 1024; -brotli_buffers 32 16k; - -brotli_types - application/atom+xml - application/javascript - application/json - application/vnd.api+json - application/rss+xml - application/x-javascript - application/xhtml+xml - application/xml - image/svg+xml - image/x-icon - text/css - text/javascript - text/plain - text/xml -; diff --git a/angie/snip.dist/http-brotli.conf.j2 b/angie/snip.dist/http-brotli.conf.j2 new file mode 100644 index 0000000..332b8d0 --- /dev/null +++ b/angie/snip.dist/http-brotli.conf.j2 @@ -0,0 +1,14 @@ +{%- from 'mime-types.compress.j2inc' import mime_types with context -%} + +## default is 6 +brotli_comp_level 5; +## default is 512k +brotli_window 64k; + +brotli_min_length 1024; +brotli_buffers 32 16k; + +brotli_types +## sourced from mime-types.compress.txt + {{ mime_types | indent(4) }} +; diff --git a/angie/snip.dist/http-gzip.conf b/angie/snip.dist/http-gzip.conf deleted file mode 100644 index 2e3f830..0000000 --- a/angie/snip.dist/http-gzip.conf +++ /dev/null @@ -1,25 +0,0 @@ -## default is 1 -gzip_comp_level 2; - -gzip_min_length 1024; -gzip_buffers 32 16k; - -gzip_vary on; -gzip_proxied any; - -gzip_types - application/atom+xml - application/javascript - application/json - application/vnd.api+json - application/rss+xml - application/x-javascript - application/xhtml+xml - application/xml - image/svg+xml - image/x-icon - text/css - text/javascript - text/plain - text/xml -; diff --git a/angie/snip.dist/http-gzip.conf.j2 b/angie/snip.dist/http-gzip.conf.j2 new file mode 100644 index 0000000..42a9ba8 --- /dev/null +++ b/angie/snip.dist/http-gzip.conf.j2 @@ -0,0 +1,15 @@ +{%- from 'mime-types.compress.j2inc' import mime_types with context -%} + +## default is 1 +gzip_comp_level 2; + +gzip_min_length 1024; +gzip_buffers 32 16k; + +gzip_vary on; +gzip_proxied any; + +gzip_types +## sourced from mime-types.compress.txt + {{ mime_types | indent(4) }} +; diff --git a/angie/snip.dist/http-zstd.conf b/angie/snip.dist/http-zstd.conf deleted file mode 100644 index 9720f81..0000000 --- a/angie/snip.dist/http-zstd.conf +++ /dev/null @@ -1,22 +0,0 @@ -## default is 1 -zstd_comp_level 2; - -zstd_min_length 1024; -zstd_buffers 32 16k; - -zstd_types - application/atom+xml - application/javascript - application/json - application/vnd.api+json - application/rss+xml - application/x-javascript - application/xhtml+xml - application/xml - image/svg+xml - image/x-icon - text/css - text/javascript - text/plain - text/xml -; diff --git a/angie/snip.dist/http-zstd.conf.j2 b/angie/snip.dist/http-zstd.conf.j2 new file mode 100644 index 0000000..751c4e6 --- /dev/null +++ b/angie/snip.dist/http-zstd.conf.j2 @@ -0,0 +1,12 @@ +{%- from 'mime-types.compress.j2inc' import mime_types with context -%} + +## default is 1 +zstd_comp_level 2; + +zstd_min_length 1024; +zstd_buffers 32 16k; + +zstd_types +## sourced from mime-types.compress.txt + {{ mime_types | indent(4) }} +; diff --git a/angie/snip.dist/mime-types.compress.j2inc b/angie/snip.dist/mime-types.compress.j2inc new file mode 100644 index 0000000..ed2f4d0 --- /dev/null +++ b/angie/snip.dist/mime-types.compress.j2inc @@ -0,0 +1,2 @@ +{%- set mime_file = pathlib.Path(os.path.join(os.getenv('NGX_MERGED_ROOT'), 'snip/mime-types.compress.txt')) -%} +{%- set mime_types = mime_file.read_text() -%} diff --git a/angie/snip.dist/mime-types.compress.txt b/angie/snip.dist/mime-types.compress.txt new file mode 100644 index 0000000..d2e12ab --- /dev/null +++ b/angie/snip.dist/mime-types.compress.txt @@ -0,0 +1,14 @@ +application/atom+xml +application/javascript +application/json +application/vnd.api+json +application/rss+xml +application/x-javascript +application/xhtml+xml +application/xml +image/svg+xml +image/x-icon +text/css +text/javascript +text/plain +text/xml \ No newline at end of file diff --git a/image-entry.d/53-expand-templates.sh b/image-entry.d/53-expand-templates.sh index 2489088..7110501 100755 --- a/image-entry.d/53-expand-templates.sh +++ b/image-entry.d/53-expand-templates.sh @@ -5,6 +5,8 @@ set -f [ "${NGX_STRICT_LOAD}" = 0 ] || set -e +export NGX_MERGED_ROOT="${merged_root}" + expand_error() { [ "${expand_error_seen:-}" = 1 ] || log_always 'template expansion has failed' expand_error_seen=1 @@ -19,12 +21,15 @@ expand_error() { dirs='conf mod modules njs site snip' [ "${NGX_PROCESS_STATIC}" = 0 ] || dirs="${dirs} static" +merge_dirs= for n in ${dirs} ; do merged_dir="${merged_root}/$n" [ -d "${merged_dir}" ] || continue - expand_dir_envsubst "${merged_dir}/" || expand_error - expand_dir_jinja "${merged_dir}/" || expand_error + merge_dirs="${merge_dirs} ${merged_dir}/" done +expand_dir_envsubst ${merge_dirs} || expand_error +expand_dir_jinja ${merge_dirs} || expand_error + exit 0 diff --git a/jinja2/j2common.py b/jinja2/j2common.py index 09fd2d0..ecf1420 100755 --- a/jinja2/j2common.py +++ b/jinja2/j2common.py @@ -9,7 +9,7 @@ import jinja2 ME = sys.argv[0] -J2_MODULES_DEFAULT = 'os os.path sys netaddr psutil re wcmatch' +J2_MODULES_DEFAULT = 'os os.path sys netaddr pathlib psutil re wcmatch' J2_SUFFIX = '.j2' J2_CFG_PATHS = [ '/angie/j2cfg',