Skip to content

Commit e36b4f5

Browse files
committed
Introduced entrypoint
This allows to launch configuration scripts on the start of container.
1 parent 1acd7f6 commit e36b4f5

File tree

16 files changed

+296
-8
lines changed

16 files changed

+296
-8
lines changed

mainline/alpine-perl/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ RUN set -x \
107107
&& ln -sf /dev/stderr /var/log/nginx/error.log \
108108
# make default server listen on ipv6
109109
&& sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' \
110-
/etc/nginx/conf.d/default.conf
110+
/etc/nginx/conf.d/default.conf \
111+
# create a docker-entrypoint.d directory
112+
&& mkdir /docker-entrypoint.d
113+
114+
COPY docker-entrypoint.sh /
115+
ENTRYPOINT ["/docker-entrypoint.sh"]
111116

112117
EXPOSE 80
113118

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
if [ "$1" = "nginx" ]; then
7+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
8+
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform an initial configuration"
9+
10+
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
11+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -executable | sort -n); do
12+
echo "$0: Launching $f";
13+
"$f"
14+
done
15+
16+
# warn on shell scripts without exec bit
17+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -not -executable); do
18+
echo "$0: Ignoring $f, not executable";
19+
done
20+
# warn on filetypes we don't know what to do with
21+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh"); do
22+
echo "$0: Ignoring $f";
23+
done
24+
25+
echo "$0: Initial configuration complete; ready for start up"
26+
else
27+
echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration"
28+
fi
29+
fi
30+
31+
exec "$@"

mainline/alpine/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ RUN set -x \
106106
&& ln -sf /dev/stderr /var/log/nginx/error.log \
107107
# make default server listen on ipv6
108108
&& sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' \
109-
/etc/nginx/conf.d/default.conf
109+
/etc/nginx/conf.d/default.conf \
110+
# create a docker-entrypoint.d directory
111+
&& mkdir /docker-entrypoint.d
112+
113+
COPY docker-entrypoint.sh /
114+
ENTRYPOINT ["/docker-entrypoint.sh"]
110115

111116
EXPOSE 80
112117

mainline/alpine/docker-entrypoint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
if [ "$1" = "nginx" ]; then
7+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
8+
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform an initial configuration"
9+
10+
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
11+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -executable | sort -n); do
12+
echo "$0: Launching $f";
13+
"$f"
14+
done
15+
16+
# warn on shell scripts without exec bit
17+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -not -executable); do
18+
echo "$0: Ignoring $f, not executable";
19+
done
20+
# warn on filetypes we don't know what to do with
21+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh"); do
22+
echo "$0: Ignoring $f";
23+
done
24+
25+
echo "$0: Initial configuration complete; ready for start up"
26+
else
27+
echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration"
28+
fi
29+
fi
30+
31+
exec "$@"

mainline/buster-perl/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ RUN set -x \
9898
&& ln -sf /dev/stderr /var/log/nginx/error.log \
9999
# make default server listen on ipv6
100100
&& sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' \
101-
/etc/nginx/conf.d/default.conf
101+
/etc/nginx/conf.d/default.conf \
102+
# create a docker-entrypoint.d directory
103+
&& mkdir /docker-entrypoint.d
104+
105+
COPY docker-entrypoint.sh /
106+
ENTRYPOINT ["/docker-entrypoint.sh"]
102107

103108
EXPOSE 80
104109

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
if [ "$1" = "nginx" ]; then
7+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
8+
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform an initial configuration"
9+
10+
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
11+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -executable | sort -n); do
12+
echo "$0: Launching $f";
13+
"$f"
14+
done
15+
16+
# warn on shell scripts without exec bit
17+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -not -executable); do
18+
echo "$0: Ignoring $f, not executable";
19+
done
20+
# warn on filetypes we don't know what to do with
21+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh"); do
22+
echo "$0: Ignoring $f";
23+
done
24+
25+
echo "$0: Initial configuration complete; ready for start up"
26+
else
27+
echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration"
28+
fi
29+
fi
30+
31+
exec "$@"

mainline/buster/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ RUN set -x \
9797
&& ln -sf /dev/stderr /var/log/nginx/error.log \
9898
# make default server listen on ipv6
9999
&& sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' \
100-
/etc/nginx/conf.d/default.conf
100+
/etc/nginx/conf.d/default.conf \
101+
# create a docker-entrypoint.d directory
102+
&& mkdir /docker-entrypoint.d
103+
104+
COPY docker-entrypoint.sh /
105+
ENTRYPOINT ["/docker-entrypoint.sh"]
101106

102107
EXPOSE 80
103108

mainline/buster/docker-entrypoint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
if [ "$1" = "nginx" ]; then
7+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
8+
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform an initial configuration"
9+
10+
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
11+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -executable | sort -n); do
12+
echo "$0: Launching $f";
13+
"$f"
14+
done
15+
16+
# warn on shell scripts without exec bit
17+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -not -executable); do
18+
echo "$0: Ignoring $f, not executable";
19+
done
20+
# warn on filetypes we don't know what to do with
21+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh"); do
22+
echo "$0: Ignoring $f";
23+
done
24+
25+
echo "$0: Initial configuration complete; ready for start up"
26+
else
27+
echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration"
28+
fi
29+
fi
30+
31+
exec "$@"

stable/alpine-perl/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ RUN set -x \
107107
&& ln -sf /dev/stderr /var/log/nginx/error.log \
108108
# make default server listen on ipv6
109109
&& sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' \
110-
/etc/nginx/conf.d/default.conf
110+
/etc/nginx/conf.d/default.conf \
111+
# create a docker-entrypoint.d directory
112+
&& mkdir /docker-entrypoint.d
113+
114+
COPY docker-entrypoint.sh /
115+
ENTRYPOINT ["/docker-entrypoint.sh"]
111116

112117
EXPOSE 80
113118

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
if [ "$1" = "nginx" ]; then
7+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
8+
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform an initial configuration"
9+
10+
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
11+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -executable | sort -n); do
12+
echo "$0: Launching $f";
13+
"$f"
14+
done
15+
16+
# warn on shell scripts without exec bit
17+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh" -not -executable); do
18+
echo "$0: Ignoring $f, not executable";
19+
done
20+
# warn on filetypes we don't know what to do with
21+
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh"); do
22+
echo "$0: Ignoring $f";
23+
done
24+
25+
echo "$0: Initial configuration complete; ready for start up"
26+
else
27+
echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration"
28+
fi
29+
fi
30+
31+
exec "$@"

0 commit comments

Comments
 (0)