From 41e39d590adb366a8ac75c4a8d8cd893a3586fd9 Mon Sep 17 00:00:00 2001 From: Achim Abeling Date: Thu, 5 Jul 2018 10:31:38 +0200 Subject: [PATCH] added another Dockerfile which allows external configuration --- sonarQuest-backend/Docker/Dockerfile2 | 17 +++++++++++++ sonarQuest-backend/Docker/README.md | 36 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 sonarQuest-backend/Docker/Dockerfile2 create mode 100644 sonarQuest-backend/Docker/README.md diff --git a/sonarQuest-backend/Docker/Dockerfile2 b/sonarQuest-backend/Docker/Dockerfile2 new file mode 100644 index 00000000..36832c82 --- /dev/null +++ b/sonarQuest-backend/Docker/Dockerfile2 @@ -0,0 +1,17 @@ +FROM maven:3.5.3-jdk-8 + + +LABEL maintainer="https://github.com/aabeling" +LABEL description="sonarquest backend with external configuration" + +COPY . /usr/src/sonarQuest +WORKDIR /usr/src/sonarQuest + +# build the executable jar +RUN mvn clean package + +EXPOSE 8080 +ENTRYPOINT java \ + -jar \ + -Dspring.config.location=/root/conf/application.properties \ + target/sonarQuest-*.jar diff --git a/sonarQuest-backend/Docker/README.md b/sonarQuest-backend/Docker/README.md new file mode 100644 index 00000000..6477d2a6 --- /dev/null +++ b/sonarQuest-backend/Docker/README.md @@ -0,0 +1,36 @@ +# Dockerfiles + +Dockerfile2 is an alternative to the `Dockerfile` which is +used with docker-compose. + +It allows an external configuration via an `application.properties` +lying on the docker host and which is made available to the +docker container via volumes. + +Build the image e.g. from within the backend folder with + +``` +$ docker build -t sonarquest-backend -f Docker/Dockerfile2 . +``` + +The image expects the configuration files to be in folder `/root/conf/`. + +Example setup with an external h2 file database: + +let `sqb` be the current directory. +Define an `application.properties` in folder `sqb` with content + +``` +spring.datasource.url=jdbc:h2:file:/tmp/sonarQuest/sonarQuest +``` + +Start the container with + +``` +docker run -v `pwd`:/root/conf -v /tmp/sonarQuestDb:/tmp/sonarQuest sonarquest-backend +``` + +The h2 database file will then be created (or used) in the host's folder +`/tmp/sonarQuestDb`. + +