Skip to content

Commit 2b0c285

Browse files
committed
Added a local resolver entrypoint script.
If enabled via NGINX_ENTRYPOINT_LOCAL_RESOLVERS variable, this script will populate NGINX_LOCAL_RESOLVERS variable that can be used in the envsubst-base templating to populate the configuration files. Fixes #673
1 parent 0cfc938 commit 2b0c285

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Dockerfile-alpine-slim.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ RUN set -x \
104104

105105
COPY docker-entrypoint.sh /
106106
COPY 10-listen-on-ipv6-by-default.sh /docker-entrypoint.d
107+
COPY 15-local-resolvers.envsh /docker-entrypoint.d
107108
COPY 20-envsubst-on-templates.sh /docker-entrypoint.d
108109
COPY 30-tune-worker-processes.sh /docker-entrypoint.d
109110
ENTRYPOINT ["/docker-entrypoint.sh"]

Dockerfile-debian.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ RUN set -x \
9797

9898
COPY docker-entrypoint.sh /
9999
COPY 10-listen-on-ipv6-by-default.sh /docker-entrypoint.d
100+
COPY 15-local-resolvers.envsh /docker-entrypoint.d
100101
COPY 20-envsubst-on-templates.sh /docker-entrypoint.d
101102
COPY 30-tune-worker-processes.sh /docker-entrypoint.d
102103
ENTRYPOINT ["/docker-entrypoint.sh"]

entrypoint/15-local-resolvers.envsh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
# vim:sw=2:ts=2:sts=2:et
3+
4+
set -eu
5+
6+
LC_ALL=C
7+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
8+
9+
if [ "${NGINX_ENTRYPOINT_LOCAL_RESOLVERS}" ]; then
10+
export NGINX_LOCAL_RESOLVERS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf)
11+
fi

0 commit comments

Comments
 (0)