From 266e7aba7f4d65a9fa65ac58b6d0ba1f14ad727b Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Thu, 1 Aug 2019 20:45:04 -0700 Subject: [PATCH] Building app in docker. Easier to override config file from /hapi-config/hapi.properties --- Dockerfile | 21 ++++++++++++++++++++- build-docker-image.bat | 1 + build-docker-image.sh | 3 +-- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 build-docker-image.bat diff --git a/Dockerfile b/Dockerfile index 8a84f1e..e1b399f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,23 @@ +# Using maven with JDK 8 +FROM maven:3.6.1-jdk-8 AS build + +# Copy pom and download dependencies. This is done here +# so that docker caches the dependencies and they don't have to be +# re-downloaded on the next run, unless the pom file changes. +COPY pom.xml . +RUN /usr/local/bin/mvn-entrypoint.sh mvn verify clean --fail-never + +# Copy all of the source code to the image and build it +COPY . . +RUN mvn package + FROM jetty:9-jre8-alpine + +COPY --from=build ./target/hapi-fhir-jpaserver.war /var/lib/jetty/webapps/hapi-fhir-jpaserver.war + +# Copy the default config file to the config directory location. It might be overridden by the docker host. +COPY --from=build ./src/main/resources/hapi.properties /hapi-config/hapi.properties + USER jetty:jetty -ADD ./target/hapi-fhir-jpaserver.war /var/lib/jetty/webapps/hapi-fhir-jpaserver.war EXPOSE 8080 +CMD ["java","-Dhapi.properties=/hapi-config/hapi.properties","-jar","/usr/local/jetty/start.jar"] \ No newline at end of file diff --git a/build-docker-image.bat b/build-docker-image.bat new file mode 100644 index 0000000..40c87e0 --- /dev/null +++ b/build-docker-image.bat @@ -0,0 +1 @@ +docker build -t hapi-fhir/hapi-fhir-jpaserver-starter . \ No newline at end of file diff --git a/build-docker-image.sh b/build-docker-image.sh index d58de22..8acade5 100755 --- a/build-docker-image.sh +++ b/build-docker-image.sh @@ -1,5 +1,4 @@ #!/bin/sh -mvn package && \ - docker build -t hapi-fhir/hapi-fhir-jpaserver-starter . +docker build -t hapi-fhir/hapi-fhir-jpaserver-starter .