From 05d23aa36a51d16ab71d1a42b313d72336010f48 Mon Sep 17 00:00:00 2001 From: Sam SIU <23556929+ssiuhk@users.noreply.github.com> Date: Thu, 18 Feb 2021 22:24:11 +0800 Subject: [PATCH] Allow turning on --verbose mode by environment variable $DEBUG - Run application by an entrypoint.sh script to allow more debug options --- docker/ddns/Dockerfile | 7 ++----- docker/ddns/entrypoint.sh | 22 ++++++++++++++++++++++ docker/docker-compose.override.yml.sample | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100755 docker/ddns/entrypoint.sh diff --git a/docker/ddns/Dockerfile b/docker/ddns/Dockerfile index 1aba4eb..7610368 100644 --- a/docker/ddns/Dockerfile +++ b/docker/ddns/Dockerfile @@ -2,6 +2,7 @@ FROM golang:alpine RUN apk add --no-cache git +COPY docker/ddns/entrypoint.sh /entrypoint.sh WORKDIR /go/src/github.com/pboehm/ddns COPY . . @@ -11,8 +12,4 @@ RUN GO111MODULE=on go install -v ./... ENV GIN_MODE release ENV DDNS_EXPIRATION_DAYS 10 -CMD /go/bin/ddns \ - --domain=${DDNS_DOMAIN} \ - --soa_fqdn=${DDNS_SOA_DOMAIN} \ - --redis=${DDNS_REDIS_HOST} \ - --expiration-days=${DDNS_EXPIRATION_DAYS} +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/ddns/entrypoint.sh b/docker/ddns/entrypoint.sh new file mode 100755 index 0000000..8348443 --- /dev/null +++ b/docker/ddns/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +if [[ $# -eq 0 ]]; then + + if [[ "${DEBUG_MODE:-false}" == "true" ]]; then + /go/bin/ddns \ + --domain=${DDNS_DOMAIN} \ + --soa_fqdn=${DDNS_SOA_DOMAIN} \ + --redis=${DDNS_REDIS_HOST} \ + --expiration-days=${DDNS_EXPIRATION_DAYS} \ + --verbose + else + /go/bin/ddns \ + --domain=${DDNS_DOMAIN} \ + --soa_fqdn=${DDNS_SOA_DOMAIN} \ + --redis=${DDNS_REDIS_HOST} \ + --expiration-days=${DDNS_EXPIRATION_DAYS} + fi + +else + "$@" +fi diff --git a/docker/docker-compose.override.yml.sample b/docker/docker-compose.override.yml.sample index 2c8e2f9..45dee20 100644 --- a/docker/docker-compose.override.yml.sample +++ b/docker/docker-compose.override.yml.sample @@ -6,6 +6,7 @@ services: DDNS_DOMAIN: d.example.net # <<< ADJUST DOMAIN DDNS_SOA_DOMAIN: ddns.example.net # <<< ADJUST DOMAIN DDNS_EXPIRATION_DAYS: 10 + DEBUG_MODE: "false" powerdns: ports: