generated from pascaliske/docker-package
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow customizing listening port via environment variable
- Loading branch information
1 parent
e6f8424
commit 14f815e
Showing
3 changed files
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,21 @@ RUN case ${TARGETPLATFORM} in \ | |
FROM alpine:3.17 | ||
LABEL maintainer="[email protected]" | ||
|
||
# environment | ||
ENV UNBOUND_PORT=5053 | ||
|
||
# install unbound | ||
RUN apk update && apk upgrade && apk add --no-cache \ | ||
gettext \ | ||
bind-tools \ | ||
openssl \ | ||
unbound | ||
|
||
# inject built files | ||
COPY --from=tini /tini /sbin/tini | ||
|
||
# inkect config files | ||
COPY config/unbound.conf /etc/unbound/unbound.conf | ||
# inject config files | ||
COPY config/unbound.conf.tpl /etc/unbound/unbound.conf.tpl | ||
|
||
# inject entrypoint | ||
COPY docker-entrypoint.sh /docker-entrypoint.sh | ||
|
@@ -38,11 +42,11 @@ COPY docker-entrypoint.sh /docker-entrypoint.sh | |
RUN echo "net.core.rmem_max=1048576" >> /etc/sysctl.conf | ||
|
||
# health check | ||
HEALTHCHECK CMD dig @127.0.0.1 -p 5053 cloudflare.com || exit 1 | ||
HEALTHCHECK CMD dig @127.0.0.1 -p ${UNBOUND_PORT} cloudflare.com || exit 1 | ||
|
||
# expose port | ||
EXPOSE 5053/tcp | ||
EXPOSE 5053/udp | ||
EXPOSE ${UNBOUND_PORT}/tcp | ||
EXPOSE ${UNBOUND_PORT}/udp | ||
|
||
# let's go! | ||
ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ server: | |
|
||
# network | ||
interface: 0.0.0.0 | ||
port: 5053 | ||
port: ${UNBOUND_PORT} | ||
|
||
# response | ||
do-ip4: yes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
#!/bin/sh | ||
# -*- coding: utf-8 -*- | ||
|
||
# dynamically set port from environment variable | ||
# shellcheck disable=SC2016 | ||
envsubst '$UNBOUND_PORT' < /etc/unbound/unbound.conf.tpl > /etc/unbound/unbound.conf | ||
|
||
# exec container command | ||
exec "$@" |