From 4662710b3757f9eecad58b679328e231bdbd4614 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 ++++++++++++++++++++++ 2 files changed, 24 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