Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
docker-nginx
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
nginxinc
docker-nginx
Commits
3591b5e4
Commit
3591b5e4
authored
May 24, 2023
by
Konstantin Pavlov
Browse files
Options
Downloads
Patches
Plain Diff
Updated mainline entrypoints after
b053826f
.
parent
123ef336
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mainline/alpine-slim/20-envsubst-on-templates.sh
+39
-0
39 additions, 0 deletions
mainline/alpine-slim/20-envsubst-on-templates.sh
mainline/debian/20-envsubst-on-templates.sh
+39
-0
39 additions, 0 deletions
mainline/debian/20-envsubst-on-templates.sh
with
78 additions
and
0 deletions
mainline/alpine-slim/20-envsubst-on-templates.sh
+
39
−
0
View file @
3591b5e4
...
@@ -10,10 +10,30 @@ entrypoint_log() {
...
@@ -10,10 +10,30 @@ entrypoint_log() {
fi
fi
}
}
add_stream_block
()
{
local
conffile
=
"/etc/nginx/nginx.conf"
if
grep
-q
-E
"
\s
*stream
\s
*
\{
"
"
$conffile
"
;
then
entrypoint_log
"
$ME
:
$conffile
contains a stream block; include
$stream_output_dir
/*.conf to enable stream templates"
else
# check if the file can be modified, e.g. not on a r/o filesystem
touch
"
$conffile
"
2>/dev/null
||
{
entrypoint_log
"
$ME
: info: can not modify
$conffile
(read-only file system?)"
;
exit
0
;
}
entrypoint_log
"
$ME
: Appending stream block to
$conffile
to include
$stream_output_dir
/*.conf"
cat
<<
END
>> "
$conffile
"
# added by "
$ME
" on "
$(
date
)
"
stream {
include
$stream_output_dir
/*.conf;
}
END
fi
}
auto_envsubst
()
{
auto_envsubst
()
{
local
template_dir
=
"
${
NGINX_ENVSUBST_TEMPLATE_DIR
:-
/etc/nginx/templates
}
"
local
template_dir
=
"
${
NGINX_ENVSUBST_TEMPLATE_DIR
:-
/etc/nginx/templates
}
"
local
suffix
=
"
${
NGINX_ENVSUBST_TEMPLATE_SUFFIX
:-
.template
}
"
local
suffix
=
"
${
NGINX_ENVSUBST_TEMPLATE_SUFFIX
:-
.template
}
"
local
output_dir
=
"
${
NGINX_ENVSUBST_OUTPUT_DIR
:-
/etc/nginx/conf.d
}
"
local
output_dir
=
"
${
NGINX_ENVSUBST_OUTPUT_DIR
:-
/etc/nginx/conf.d
}
"
local
stream_suffix
=
"
${
NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX
:-
.stream-template
}
"
local
stream_output_dir
=
"
${
NGINX_ENVSUBST_STREAM_OUTPUT_DIR
:-
/etc/nginx/stream-conf.d
}
"
local
filter
=
"
${
NGINX_ENVSUBST_FILTER
:-}
"
local
filter
=
"
${
NGINX_ENVSUBST_FILTER
:-}
"
local
template defined_envs relative_path output_path subdir
local
template defined_envs relative_path output_path subdir
...
@@ -32,6 +52,25 @@ auto_envsubst() {
...
@@ -32,6 +52,25 @@ auto_envsubst() {
entrypoint_log
"
$ME
: Running envsubst on
$template
to
$output_path
"
entrypoint_log
"
$ME
: Running envsubst on
$template
to
$output_path
"
envsubst
"
$defined_envs
"
<
"
$template
"
>
"
$output_path
"
envsubst
"
$defined_envs
"
<
"
$template
"
>
"
$output_path
"
done
done
# Print the first file with the stream suffix, this will be false if there are none
if
test
-n
"
$(
find
"
$template_dir
"
-name
"*
$stream_suffix
"
-print
-quit
)
"
;
then
mkdir
-p
"
$stream_output_dir
"
if
[
!
-w
"
$stream_output_dir
"
]
;
then
entrypoint_log
"
$ME
: ERROR:
$template_dir
exists, but
$stream_output_dir
is not writable"
return
0
fi
add_stream_block
find
"
$template_dir
"
-follow
-type
f
-name
"*
$stream_suffix
"
-print
|
while
read
-r
template
;
do
relative_path
=
"
${
template
#
$template_dir
/
}
"
output_path
=
"
$stream_output_dir
/
${
relative_path
%
$stream_suffix
}
"
subdir
=
$(
dirname
"
$relative_path
"
)
# create a subdirectory where the template file exists
mkdir
-p
"
$stream_output_dir
/
$subdir
"
entrypoint_log
"
$ME
: Running envsubst on
$template
to
$output_path
"
envsubst
"
$defined_envs
"
<
"
$template
"
>
"
$output_path
"
done
fi
}
}
auto_envsubst
auto_envsubst
...
...
This diff is collapsed.
Click to expand it.
mainline/debian/20-envsubst-on-templates.sh
+
39
−
0
View file @
3591b5e4
...
@@ -10,10 +10,30 @@ entrypoint_log() {
...
@@ -10,10 +10,30 @@ entrypoint_log() {
fi
fi
}
}
add_stream_block
()
{
local
conffile
=
"/etc/nginx/nginx.conf"
if
grep
-q
-E
"
\s
*stream
\s
*
\{
"
"
$conffile
"
;
then
entrypoint_log
"
$ME
:
$conffile
contains a stream block; include
$stream_output_dir
/*.conf to enable stream templates"
else
# check if the file can be modified, e.g. not on a r/o filesystem
touch
"
$conffile
"
2>/dev/null
||
{
entrypoint_log
"
$ME
: info: can not modify
$conffile
(read-only file system?)"
;
exit
0
;
}
entrypoint_log
"
$ME
: Appending stream block to
$conffile
to include
$stream_output_dir
/*.conf"
cat
<<
END
>> "
$conffile
"
# added by "
$ME
" on "
$(
date
)
"
stream {
include
$stream_output_dir
/*.conf;
}
END
fi
}
auto_envsubst
()
{
auto_envsubst
()
{
local
template_dir
=
"
${
NGINX_ENVSUBST_TEMPLATE_DIR
:-
/etc/nginx/templates
}
"
local
template_dir
=
"
${
NGINX_ENVSUBST_TEMPLATE_DIR
:-
/etc/nginx/templates
}
"
local
suffix
=
"
${
NGINX_ENVSUBST_TEMPLATE_SUFFIX
:-
.template
}
"
local
suffix
=
"
${
NGINX_ENVSUBST_TEMPLATE_SUFFIX
:-
.template
}
"
local
output_dir
=
"
${
NGINX_ENVSUBST_OUTPUT_DIR
:-
/etc/nginx/conf.d
}
"
local
output_dir
=
"
${
NGINX_ENVSUBST_OUTPUT_DIR
:-
/etc/nginx/conf.d
}
"
local
stream_suffix
=
"
${
NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX
:-
.stream-template
}
"
local
stream_output_dir
=
"
${
NGINX_ENVSUBST_STREAM_OUTPUT_DIR
:-
/etc/nginx/stream-conf.d
}
"
local
filter
=
"
${
NGINX_ENVSUBST_FILTER
:-}
"
local
filter
=
"
${
NGINX_ENVSUBST_FILTER
:-}
"
local
template defined_envs relative_path output_path subdir
local
template defined_envs relative_path output_path subdir
...
@@ -32,6 +52,25 @@ auto_envsubst() {
...
@@ -32,6 +52,25 @@ auto_envsubst() {
entrypoint_log
"
$ME
: Running envsubst on
$template
to
$output_path
"
entrypoint_log
"
$ME
: Running envsubst on
$template
to
$output_path
"
envsubst
"
$defined_envs
"
<
"
$template
"
>
"
$output_path
"
envsubst
"
$defined_envs
"
<
"
$template
"
>
"
$output_path
"
done
done
# Print the first file with the stream suffix, this will be false if there are none
if
test
-n
"
$(
find
"
$template_dir
"
-name
"*
$stream_suffix
"
-print
-quit
)
"
;
then
mkdir
-p
"
$stream_output_dir
"
if
[
!
-w
"
$stream_output_dir
"
]
;
then
entrypoint_log
"
$ME
: ERROR:
$template_dir
exists, but
$stream_output_dir
is not writable"
return
0
fi
add_stream_block
find
"
$template_dir
"
-follow
-type
f
-name
"*
$stream_suffix
"
-print
|
while
read
-r
template
;
do
relative_path
=
"
${
template
#
$template_dir
/
}
"
output_path
=
"
$stream_output_dir
/
${
relative_path
%
$stream_suffix
}
"
subdir
=
$(
dirname
"
$relative_path
"
)
# create a subdirectory where the template file exists
mkdir
-p
"
$stream_output_dir
/
$subdir
"
entrypoint_log
"
$ME
: Running envsubst on
$template
to
$output_path
"
envsubst
"
$defined_envs
"
<
"
$template
"
>
"
$output_path
"
done
fi
}
}
auto_envsubst
auto_envsubst
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment