From 62dbe1740aafe2f228bd364d88bc2090dd4ca1a2 Mon Sep 17 00:00:00 2001 From: olblak Date: Tue, 9 May 2017 17:01:48 +0200 Subject: [PATCH] Add election_logdir support --- Dockerfile | 16 +++++++++------- config.properties.example | 2 +- docker-compose.yaml | 2 +- entrypoint.sh | 11 +++++++++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8145ed..434e029 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,14 +5,16 @@ LABEL \ Project="https://github.com/jenkins-infra/account-app" \ Maintainer="infra@lists.jenkins-ci.org" +ENV ELECTION_LOGDIR=/var/log/accountapp/elections + EXPOSE 8080 ENV CIRCUIT_BREAKER_FILE /etc/accountapp/circuitBreaker.txt # /home/jetty/.app is apparently needed by Stapler for some weird reason. O_O -RUN \ - mkdir -p /home/jetty/.app &&\ - mkdir -p /etc/accountapp +RUN mkdir -p /home/jetty/.app &&\ + mkdir -p /etc/accountapp &&\ + mkdir -p $ELECTION_LOGDIR COPY config.properties.example /etc/accountapp/config.properties.example COPY circuitBreaker.txt /etc/accountapp/circuitBreaker.txt @@ -20,10 +22,10 @@ COPY entrypoint.sh /entrypoint.sh COPY build/libs/accountapp*.war /var/lib/jetty/webapps/ROOT.war -RUN \ - chmod 0755 /entrypoint.sh &&\ - chown -R jetty:root /etc/accountapp &&\ - chown -R jetty:root /var/lib/jetty +RUN chmod 0755 /entrypoint.sh &&\ + chown -R jetty:root /etc/accountapp &&\ + chown -R jetty:root /var/lib/jetty &&\ + chown -R jetty:root $ELECTION_LOGDIR USER jetty diff --git a/config.properties.example b/config.properties.example index 0fc6eee..dc5767a 100644 --- a/config.properties.example +++ b/config.properties.example @@ -22,6 +22,6 @@ circuitBreakerFile=CIRCUIT_BREAKER_FILE electionCandidates=ELECTION_CANDIDATES electionClose=ELECTION_CLOSE electionOpen= ELECTION_OPEN -electionLogfile=ELECTION_LOGFILE +electionLogDir=ELECTION_LOGDIR # vim: ft=conf diff --git a/docker-compose.yaml b/docker-compose.yaml index cc1f487..c091533 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,6 @@ version: '3' services: - app: + run: build: . image: accountapp:latest env_file: .env diff --git a/entrypoint.sh b/entrypoint.sh index 77c1698..9b35431 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,7 +22,14 @@ init_config_properties() { : "${ELECTION_CANDIDATES:? Required coma separated list of candidates}" : "${ELECTION_CLOSE:? Required date election will close. yyyy/MM/dd}" : "${ELECTION_OPEN:? date election will open. yyyy/MM/dd }" - : "${ELECTION_LOGFILE:? path to store collected votes. assume this path is well persisted/backup }" + : "${ELECTION_LOGDIR:? Require election log directory }" + + #Directory to store collected votes. assume this path is well persisted/backup + + if [ ! -d "${ELECTION_LOGDIR}" ]; then + mkdir -p "${ELECTION_LOGDIR}" + chown jetty: "$ELECTION_LOGDIR" + fi cp /etc/accountapp/config.properties.example /etc/accountapp/config.properties @@ -39,7 +46,7 @@ init_config_properties() { sed -i "s#ELECTION_CANDIDATES#$ELECTION_CANDIDATES#" /etc/accountapp/config.properties sed -i "s#ELECTION_OPEN#$ELECTION_OPEN#" /etc/accountapp/config.properties sed -i "s#ELECTION_CLOSE#$ELECTION_CLOSE#" /etc/accountapp/config.properties - sed -i "s#ELECTION_LOGFILE#$ELECTION_LOGFILE#" /etc/accountapp/config.properties + sed -i "s#ELECTION_LOGDIR#$ELECTION_LOGDIR#" /etc/accountapp/config.properties } if [ ! -f /etc/accountapp/config.properties ]; then