Skip to content

Commit 8a38711

Browse files
committed
Update mainline NGINX to 1.25.0
* And mainline NJS to 0.7.12 * Add stream templating
1 parent 9a8b6d6 commit 8a38711

File tree

11 files changed

+208
-13
lines changed

11 files changed

+208
-13
lines changed

entrypoint/20-envsubst-on-templates.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@ entrypoint_log() {
1010
fi
1111
}
1212

13+
add_stream_block() {
14+
local conffile="/etc/nginx/nginx.conf"
15+
16+
if grep -q -E "\s*stream\s*\{" "$conffile"; then
17+
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
18+
else
19+
# check if the file can be modified, e.g. not on a r/o filesystem
20+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21+
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
22+
cat << END >> "$conffile"
23+
# added by "$ME" on "$(date)"
24+
stream {
25+
include $stream_output_dir/*.conf;
26+
}
27+
END
28+
fi
29+
}
30+
1331
auto_envsubst() {
1432
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
1533
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
1634
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
35+
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
36+
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
1737
local filter="${NGINX_ENVSUBST_FILTER:-}"
1838

1939
local template defined_envs relative_path output_path subdir
@@ -32,6 +52,25 @@ auto_envsubst() {
3252
entrypoint_log "$ME: Running envsubst on $template to $output_path"
3353
envsubst "$defined_envs" < "$template" > "$output_path"
3454
done
55+
56+
# Print the first file with the stream suffix, this will be false if there are none
57+
if test -n "$(find "$template_dir" -name "*$stream_suffix" -print -quit)"; then
58+
mkdir -p "$stream_output_dir"
59+
if [ ! -w "$stream_output_dir" ]; then
60+
entrypoint_log "$ME: ERROR: $template_dir exists, but $stream_output_dir is not writable"
61+
return 0
62+
fi
63+
add_stream_block
64+
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65+
relative_path="${template#$template_dir/}"
66+
output_path="$stream_output_dir/${relative_path%$stream_suffix}"
67+
subdir=$(dirname "$relative_path")
68+
# create a subdirectory where the template file exists
69+
mkdir -p "$stream_output_dir/$subdir"
70+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
envsubst "$defined_envs" < "$template" > "$output_path"
72+
done
73+
fi
3574
}
3675

3776
auto_envsubst

mainline/alpine-perl/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# PLEASE DO NOT EDIT IT DIRECTLY.
55
#
6-
ARG IMAGE=nginxinc/nginx-unprivileged:1.23.4-alpine
6+
ARG IMAGE=nginxinc/nginx-unprivileged:1.25.0-alpine
77
FROM $IMAGE
88

99
ARG UID=101
@@ -61,7 +61,7 @@ RUN set -x \
6161
export HOME=${tempDir} \
6262
&& cd ${tempDir} \
6363
&& curl -f -O https://hg.nginx.org/pkg-oss/archive/${NGINX_VERSION}-${PKG_RELEASE}.tar.gz \
64-
&& PKGOSSCHECKSUM=\"8f3f6c1ddd984c0c7320d3bea25eee42749db6d69c251223cf91d69b8d80b703ab39eb94fcf731399a7693ebd8dd37d1b3232ea1184ca98e5ca0ba6165e1a05c *${NGINX_VERSION}-${PKG_RELEASE}.tar.gz\" \
64+
&& PKGOSSCHECKSUM=\"18bee4bd498e0b8da765e8cd2d824e1027d40fd95d55fd59339cdb5d5e0e633795f4196c76045e86027cdfc6ab05a3cc0d39b25bd0a967f1edd47910d813262a *${NGINX_VERSION}-${PKG_RELEASE}.tar.gz\" \
6565
&& if [ \"\$(openssl sha512 -r ${NGINX_VERSION}-${PKG_RELEASE}.tar.gz)\" = \"\$PKGOSSCHECKSUM\" ]; then \
6666
echo \"pkg-oss tarball checksum verification succeeded!\"; \
6767
else \

mainline/alpine-slim/20-envsubst-on-templates.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@ entrypoint_log() {
1010
fi
1111
}
1212

13+
add_stream_block() {
14+
local conffile="/etc/nginx/nginx.conf"
15+
16+
if grep -q -E "\s*stream\s*\{" "$conffile"; then
17+
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
18+
else
19+
# check if the file can be modified, e.g. not on a r/o filesystem
20+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21+
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
22+
cat << END >> "$conffile"
23+
# added by "$ME" on "$(date)"
24+
stream {
25+
include $stream_output_dir/*.conf;
26+
}
27+
END
28+
fi
29+
}
30+
1331
auto_envsubst() {
1432
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
1533
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
1634
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
35+
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
36+
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
1737
local filter="${NGINX_ENVSUBST_FILTER:-}"
1838

1939
local template defined_envs relative_path output_path subdir
@@ -32,6 +52,25 @@ auto_envsubst() {
3252
entrypoint_log "$ME: Running envsubst on $template to $output_path"
3353
envsubst "$defined_envs" < "$template" > "$output_path"
3454
done
55+
56+
# Print the first file with the stream suffix, this will be false if there are none
57+
if test -n "$(find "$template_dir" -name "*$stream_suffix" -print -quit)"; then
58+
mkdir -p "$stream_output_dir"
59+
if [ ! -w "$stream_output_dir" ]; then
60+
entrypoint_log "$ME: ERROR: $template_dir exists, but $stream_output_dir is not writable"
61+
return 0
62+
fi
63+
add_stream_block
64+
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65+
relative_path="${template#$template_dir/}"
66+
output_path="$stream_output_dir/${relative_path%$stream_suffix}"
67+
subdir=$(dirname "$relative_path")
68+
# create a subdirectory where the template file exists
69+
mkdir -p "$stream_output_dir/$subdir"
70+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
envsubst "$defined_envs" < "$template" > "$output_path"
72+
done
73+
fi
3574
}
3675

3776
auto_envsubst

mainline/alpine-slim/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FROM $IMAGE
88

99
LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
1010

11-
ENV NGINX_VERSION 1.23.4
11+
ENV NGINX_VERSION 1.25.0
1212
ENV PKG_RELEASE 1
1313

1414
ARG UID=101
@@ -61,7 +61,7 @@ RUN set -x \
6161
export HOME=${tempDir} \
6262
&& cd ${tempDir} \
6363
&& curl -f -O https://hg.nginx.org/pkg-oss/archive/${NGINX_VERSION}-${PKG_RELEASE}.tar.gz \
64-
&& PKGOSSCHECKSUM=\"8f3f6c1ddd984c0c7320d3bea25eee42749db6d69c251223cf91d69b8d80b703ab39eb94fcf731399a7693ebd8dd37d1b3232ea1184ca98e5ca0ba6165e1a05c *${NGINX_VERSION}-${PKG_RELEASE}.tar.gz\" \
64+
&& PKGOSSCHECKSUM=\"18bee4bd498e0b8da765e8cd2d824e1027d40fd95d55fd59339cdb5d5e0e633795f4196c76045e86027cdfc6ab05a3cc0d39b25bd0a967f1edd47910d813262a *${NGINX_VERSION}-${PKG_RELEASE}.tar.gz\" \
6565
&& if [ \"\$(openssl sha512 -r ${NGINX_VERSION}-${PKG_RELEASE}.tar.gz)\" = \"\$PKGOSSCHECKSUM\" ]; then \
6666
echo \"pkg-oss tarball checksum verification succeeded!\"; \
6767
else \

mainline/alpine/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#
44
# PLEASE DO NOT EDIT IT DIRECTLY.
55
#
6-
ARG IMAGE=nginxinc/nginx-unprivileged:1.23.4-alpine-slim
6+
ARG IMAGE=nginxinc/nginx-unprivileged:1.25.0-alpine-slim
77
FROM $IMAGE
88

9-
ENV NJS_VERSION 0.7.11
9+
ENV NJS_VERSION 0.7.12
1010

1111
ARG UID=101
1212
ARG GID=101
@@ -65,7 +65,7 @@ RUN set -x \
6565
export HOME=${tempDir} \
6666
&& cd ${tempDir} \
6767
&& curl -f -O https://hg.nginx.org/pkg-oss/archive/${NGINX_VERSION}-${PKG_RELEASE}.tar.gz \
68-
&& PKGOSSCHECKSUM=\"8f3f6c1ddd984c0c7320d3bea25eee42749db6d69c251223cf91d69b8d80b703ab39eb94fcf731399a7693ebd8dd37d1b3232ea1184ca98e5ca0ba6165e1a05c *${NGINX_VERSION}-${PKG_RELEASE}.tar.gz\" \
68+
&& PKGOSSCHECKSUM=\"18bee4bd498e0b8da765e8cd2d824e1027d40fd95d55fd59339cdb5d5e0e633795f4196c76045e86027cdfc6ab05a3cc0d39b25bd0a967f1edd47910d813262a *${NGINX_VERSION}-${PKG_RELEASE}.tar.gz\" \
6969
&& if [ \"\$(openssl sha512 -r ${NGINX_VERSION}-${PKG_RELEASE}.tar.gz)\" = \"\$PKGOSSCHECKSUM\" ]; then \
7070
echo \"pkg-oss tarball checksum verification succeeded!\"; \
7171
else \

mainline/debian-perl/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# PLEASE DO NOT EDIT IT DIRECTLY.
55
#
6-
ARG IMAGE=nginxinc/nginx-unprivileged:1.23.4
6+
ARG IMAGE=nginxinc/nginx-unprivileged:1.25.0
77
FROM $IMAGE
88

99
ARG UID=101

mainline/debian/20-envsubst-on-templates.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@ entrypoint_log() {
1010
fi
1111
}
1212

13+
add_stream_block() {
14+
local conffile="/etc/nginx/nginx.conf"
15+
16+
if grep -q -E "\s*stream\s*\{" "$conffile"; then
17+
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
18+
else
19+
# check if the file can be modified, e.g. not on a r/o filesystem
20+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21+
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
22+
cat << END >> "$conffile"
23+
# added by "$ME" on "$(date)"
24+
stream {
25+
include $stream_output_dir/*.conf;
26+
}
27+
END
28+
fi
29+
}
30+
1331
auto_envsubst() {
1432
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
1533
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
1634
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
35+
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
36+
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
1737
local filter="${NGINX_ENVSUBST_FILTER:-}"
1838

1939
local template defined_envs relative_path output_path subdir
@@ -32,6 +52,25 @@ auto_envsubst() {
3252
entrypoint_log "$ME: Running envsubst on $template to $output_path"
3353
envsubst "$defined_envs" < "$template" > "$output_path"
3454
done
55+
56+
# Print the first file with the stream suffix, this will be false if there are none
57+
if test -n "$(find "$template_dir" -name "*$stream_suffix" -print -quit)"; then
58+
mkdir -p "$stream_output_dir"
59+
if [ ! -w "$stream_output_dir" ]; then
60+
entrypoint_log "$ME: ERROR: $template_dir exists, but $stream_output_dir is not writable"
61+
return 0
62+
fi
63+
add_stream_block
64+
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65+
relative_path="${template#$template_dir/}"
66+
output_path="$stream_output_dir/${relative_path%$stream_suffix}"
67+
subdir=$(dirname "$relative_path")
68+
# create a subdirectory where the template file exists
69+
mkdir -p "$stream_output_dir/$subdir"
70+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
envsubst "$defined_envs" < "$template" > "$output_path"
72+
done
73+
fi
3574
}
3675

3776
auto_envsubst

mainline/debian/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ FROM $IMAGE
88

99
LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
1010

11-
ENV NGINX_VERSION 1.23.4
12-
ENV NJS_VERSION 0.7.11
11+
ENV NGINX_VERSION 1.25.0
12+
ENV NJS_VERSION 0.7.12
1313
ENV PKG_RELEASE 1~bullseye
1414

1515
ARG UID=101

stable/alpine-slim/20-envsubst-on-templates.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@ entrypoint_log() {
1010
fi
1111
}
1212

13+
add_stream_block() {
14+
local conffile="/etc/nginx/nginx.conf"
15+
16+
if grep -q -E "\s*stream\s*\{" "$conffile"; then
17+
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
18+
else
19+
# check if the file can be modified, e.g. not on a r/o filesystem
20+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21+
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
22+
cat << END >> "$conffile"
23+
# added by "$ME" on "$(date)"
24+
stream {
25+
include $stream_output_dir/*.conf;
26+
}
27+
END
28+
fi
29+
}
30+
1331
auto_envsubst() {
1432
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
1533
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
1634
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
35+
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
36+
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
1737
local filter="${NGINX_ENVSUBST_FILTER:-}"
1838

1939
local template defined_envs relative_path output_path subdir
@@ -32,6 +52,25 @@ auto_envsubst() {
3252
entrypoint_log "$ME: Running envsubst on $template to $output_path"
3353
envsubst "$defined_envs" < "$template" > "$output_path"
3454
done
55+
56+
# Print the first file with the stream suffix, this will be false if there are none
57+
if test -n "$(find "$template_dir" -name "*$stream_suffix" -print -quit)"; then
58+
mkdir -p "$stream_output_dir"
59+
if [ ! -w "$stream_output_dir" ]; then
60+
entrypoint_log "$ME: ERROR: $template_dir exists, but $stream_output_dir is not writable"
61+
return 0
62+
fi
63+
add_stream_block
64+
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65+
relative_path="${template#$template_dir/}"
66+
output_path="$stream_output_dir/${relative_path%$stream_suffix}"
67+
subdir=$(dirname "$relative_path")
68+
# create a subdirectory where the template file exists
69+
mkdir -p "$stream_output_dir/$subdir"
70+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
envsubst "$defined_envs" < "$template" > "$output_path"
72+
done
73+
fi
3574
}
3675

3776
auto_envsubst

stable/debian/20-envsubst-on-templates.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@ entrypoint_log() {
1010
fi
1111
}
1212

13+
add_stream_block() {
14+
local conffile="/etc/nginx/nginx.conf"
15+
16+
if grep -q -E "\s*stream\s*\{" "$conffile"; then
17+
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
18+
else
19+
# check if the file can be modified, e.g. not on a r/o filesystem
20+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21+
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
22+
cat << END >> "$conffile"
23+
# added by "$ME" on "$(date)"
24+
stream {
25+
include $stream_output_dir/*.conf;
26+
}
27+
END
28+
fi
29+
}
30+
1331
auto_envsubst() {
1432
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
1533
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
1634
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
35+
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
36+
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
1737
local filter="${NGINX_ENVSUBST_FILTER:-}"
1838

1939
local template defined_envs relative_path output_path subdir
@@ -32,6 +52,25 @@ auto_envsubst() {
3252
entrypoint_log "$ME: Running envsubst on $template to $output_path"
3353
envsubst "$defined_envs" < "$template" > "$output_path"
3454
done
55+
56+
# Print the first file with the stream suffix, this will be false if there are none
57+
if test -n "$(find "$template_dir" -name "*$stream_suffix" -print -quit)"; then
58+
mkdir -p "$stream_output_dir"
59+
if [ ! -w "$stream_output_dir" ]; then
60+
entrypoint_log "$ME: ERROR: $template_dir exists, but $stream_output_dir is not writable"
61+
return 0
62+
fi
63+
add_stream_block
64+
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65+
relative_path="${template#$template_dir/}"
66+
output_path="$stream_output_dir/${relative_path%$stream_suffix}"
67+
subdir=$(dirname "$relative_path")
68+
# create a subdirectory where the template file exists
69+
mkdir -p "$stream_output_dir/$subdir"
70+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
envsubst "$defined_envs" < "$template" > "$output_path"
72+
done
73+
fi
3574
}
3675

3776
auto_envsubst

0 commit comments

Comments
 (0)