From 745f6e3627769b058bddcd1a2b9216537cb026a5 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Fri, 1 Sep 2017 15:02:54 +0200 Subject: [PATCH 1/3] add Dockerfile --- Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 5 +++++ pom.xml | 12 ++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..19268e354a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM tomcat:8.0-jre7 +ENV LANG en_US.UTF-8 + +EXPOSE 8080 + +# set default secrets ( override for production use! ) +# consoleSecretKey="deegree" +ENV consoleSecretKey=000001544E797221:564344F65B8F9DDBA6A410E461E7801E10955F56D8679284966F400C68B6CEAB +ENV apiUser=deegree +ENV apiPass=deegree + +RUN mkdir /root/.deegree && \ + mkdir /build && \ + rm -r /usr/local/tomcat/webapps/ROOT + +COPY ./ /build/ + +# build deegree, extract it and clean up +RUN apt-get update && apt-get install -y --no-install-recommends default-jdk maven && \ + cd /build/ && \ + mvn clean install -DskipTests && \ + cp /build/deegree-services/deegree-webservices/target/deegree-webservices-*.war /usr/local/tomcat/webapps/ROOT.war && \ + cd / && \ + mkdir /usr/local/tomcat/webapps/ROOT && \ + unzip -o /usr/local/tomcat/webapps/ROOT.war -d /usr/local/tomcat/webapps/ROOT && \ + rm -r /build/ && rm -r /root/.m2 && rm /usr/local/tomcat/webapps/ROOT.war && \ + apt-get purge -y --auto-remove default-jdk maven && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +#cmd: +# 1. configure deegreeapi access +# 2. configure console access +# 3. start tomcat +CMD sed -i '44i /' /usr/local/tomcat/conf/tomcat-users.xml \ + && echo $consoleSecretKey >/root/.deegree/console.pw \ + && /usr/local/tomcat/bin/catalina.sh run diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..07c1db3164 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +# simple compose file for running the Docker image +deegree: + build: . + ports: + - "8080:8080" diff --git a/pom.xml b/pom.xml index ac450f416a..72c0efa31e 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,18 @@ true + + + wetransform-repo + https://artifactory.wetransform.to/artifactory/deegree + + never + + + false + + From 93569adf62f6ff551c8b20b1d1cbe11a2c393f19 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Fri, 11 Aug 2017 15:34:36 +0200 Subject: [PATCH 2/3] multi stage Docker file and build labels --- Dockerfile | 39 +++++++++++++++++++++++++-------------- hooks/build | 17 +++++++++++++++++ 2 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 hooks/build diff --git a/Dockerfile b/Dockerfile index 19268e354a..96193148bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,30 @@ +FROM java:7-jdk as builder +# Multi stage build - https://docs.docker.com/engine/userguide/eng-image/multistage-build/ + +# install maven +RUN apt-get update && apt-get install -y --no-install-recommends maven + +# build and extract deegree +RUN mkdir /build && mkdir /target +COPY ./ /build/ +RUN cd /build/ && \ + mvn clean install -DskipTests && \ + cp /build/deegree-services/deegree-webservices/target/deegree-webservices-*.war /build/deegree-webservices.war && \ + unzip -o /build/deegree-webservices.war -d /target + +# add to image... FROM tomcat:8.0-jre7 ENV LANG en_US.UTF-8 +# add build info - see hooks/build and http://label-schema.org/ +ARG BUILD_DATE +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.schema-version="1.0.0-rc1" + EXPOSE 8080 # set default secrets ( override for production use! ) @@ -10,22 +34,9 @@ ENV apiUser=deegree ENV apiPass=deegree RUN mkdir /root/.deegree && \ - mkdir /build && \ rm -r /usr/local/tomcat/webapps/ROOT -COPY ./ /build/ - -# build deegree, extract it and clean up -RUN apt-get update && apt-get install -y --no-install-recommends default-jdk maven && \ - cd /build/ && \ - mvn clean install -DskipTests && \ - cp /build/deegree-services/deegree-webservices/target/deegree-webservices-*.war /usr/local/tomcat/webapps/ROOT.war && \ - cd / && \ - mkdir /usr/local/tomcat/webapps/ROOT && \ - unzip -o /usr/local/tomcat/webapps/ROOT.war -d /usr/local/tomcat/webapps/ROOT && \ - rm -r /build/ && rm -r /root/.m2 && rm /usr/local/tomcat/webapps/ROOT.war && \ - apt-get purge -y --auto-remove default-jdk maven && \ - apt-get clean && rm -rf /var/lib/apt/lists/* +COPY --from=builder /target /usr/local/tomcat/webapps/ROOT #cmd: # 1. configure deegreeapi access diff --git a/hooks/build b/hooks/build new file mode 100644 index 0000000000..f15293185d --- /dev/null +++ b/hooks/build @@ -0,0 +1,17 @@ +#!/bin/bash + +# see https://medium.com/microscaling-systems/labelling-automated-builds-on-docker-hub-f3d073fb8e1 +# and https://docs.docker.com/docker-cloud/builds/advanced/#override-build-test-or-push-commands + +# $IMAGE_NAME var is injected into the build so the tag is correct. + +echo "Build hook running" +docker build \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VCS_REF=`git rev-parse HEAD` \ + --build-arg VCS_URL=`git ls-remote --get-url origin` \ + -t $IMAGE_NAME . + +# Other options for getting VCS URL: +# git remote get-url origin # seems to be not available on Docker Hub +# git config --get remote.origin.url From 429b08534bc99ddeffbba8e264b105a72d22de57 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Thu, 7 Sep 2017 17:18:39 +0200 Subject: [PATCH 3/3] configure for publishing in wetransform artifactory Command: `mvn clean deploy -DskipTests` For authentication to artifactory a settings.xml is required (e.g. in `~/.m2/settings.xml`) https://maven.apache.org/settings.html There for each repo the user and password need to be configured: http://maven.apache.org/plugins/maven-deploy-plugin/usage.html --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 72c0efa31e..5d9be36432 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ + apidoc.deegree.org file:///tmp/site/${project.version}/ + + wetf-releases + https://artifactory.wetransform.to/artifactory/deegree-release-local + + + wetf-snapshots + https://artifactory.wetransform.to/artifactory/deegree-snapshot-local +