Dockerfile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. FROM maven:3.5-jdk-8-alpine as builder
  2. ARG LOCAL_MAVEN_MIRROR=http://maven.aliyun.com/nexus/content/groups/public/
  3. # used to edit maven settings.xml
  4. RUN apk add --no-cache xmlstarlet
  5. # change default local repository location. parent image set ~/.m2 as volume, so data won't be persisted for following build cmds
  6. RUN xmlstarlet ed --inplace -N 's=http://maven.apache.org/SETTINGS/1.0.0' \
  7. --subnode '/s:settings' --type elem -n localRepository -v '${user.home}/m2/repository' \
  8. /usr/share/maven/conf/settings.xml
  9. RUN if test -n "$LOCAL_MAVEN_MIRROR"; then \
  10. xmlstarlet ed --inplace -N 's=http://maven.apache.org/SETTINGS/1.0.0' \
  11. --subnode '/s:settings/s:mirrors' --type elem -n mirror -v '' \
  12. /usr/share/maven/conf/settings.xml \
  13. && xmlstarlet ed --inplace -N 's=http://maven.apache.org/SETTINGS/1.0.0' \
  14. --subnode '/s:settings/s:mirrors/s:mirror' --type elem -n id -v 'custom-mirror' \
  15. /usr/share/maven/conf/settings.xml \
  16. && xmlstarlet ed --inplace -N 's=http://maven.apache.org/SETTINGS/1.0.0' \
  17. --subnode '/s:settings/s:mirrors/s:mirror' --type elem -n name -v 'custom-mirror' \
  18. /usr/share/maven/conf/settings.xml \
  19. && xmlstarlet ed --inplace -N 's=http://maven.apache.org/SETTINGS/1.0.0' \
  20. --subnode '/s:settings/s:mirrors/s:mirror' --type elem -n url -v "$LOCAL_MAVEN_MIRROR" \
  21. /usr/share/maven/conf/settings.xml \
  22. && xmlstarlet ed --inplace -N 's=http://maven.apache.org/SETTINGS/1.0.0' \
  23. --subnode '/s:settings/s:mirrors/s:mirror' --type elem -n mirrorOf -v 'central' \
  24. /usr/share/maven/conf/settings.xml \
  25. ;fi
  26. # copy lib/ and src/ seperately to leverage cache (lib/ rarely changes)
  27. COPY ./lib /DWSurvey/lib
  28. RUN mvn install:install-file -Dfile=/DWSurvey/lib/QRCode.jar -DgroupId=net.qrcode -DartifactId=qrcode -Dversion=1.0 -Dpackaging=jar
  29. RUN mvn install:install-file -Dfile=/DWSurvey/lib/spssw-1.66.jar -DgroupId=net.spssw -DartifactId=spssw -Dversion=1.66 -Dpackaging=jar
  30. RUN mvn install:install-file -Dfile=/DWSurvey/lib/xssProtect-0.1.jar -DgroupId=net.xssprotect -DartifactId=xssprotest -Dversion=1.0 -Dpackaging=jar
  31. # if pom.xml is not updates, m2/ may be cached as well
  32. COPY pom.xml /DWSurvey/pom.xml
  33. RUN cd /DWSurvey && mvn dependency:resolve
  34. # copy src/ and build, src changes constantly
  35. COPY ./src /DWSurvey/src
  36. RUN cd /DWSurvey \
  37. && find /DWSurvey/src -type f -exec chmod 640 {} \; \
  38. && mvn install
  39. # ------------------------- 8< -------------------------
  40. # there is a bug with 8.0-jre8-alpine, which was introduced in alpine3.6
  41. # see: https://bugs.alpinelinux.org/issues/7372
  42. # image layers: tomcat:8.0-jre8 -> openjdk:8-jre-alpine -> alpine:3.6
  43. # let's switch to 8.0-jre8-alpine after alpine has fixed the bug (alpine 3.6.3 release)
  44. #FROM tomcat:8.0-jre8-alpine
  45. FROM davidcaste/alpine-tomcat:jre8tomcat8
  46. ENV MYSQL_HOST= MYSQL_PORT=3306 MYSQL_DATABASE= MYSQL_USER= MYSQL_PASSWORD=
  47. ENV ADMIN_EMAIL= ADMIN_PASSWORD=
  48. ENV CONTEXT_ROOT=/
  49. RUN apk add --no-cache mysql-client
  50. COPY --from=builder /DWSurvey/target/diaowen.war /diaowen.war
  51. COPY docker-entry.sh /docker-entry.sh
  52. # TODO this is a dirty hack
  53. VOLUME ["/dwsurvey/WEB-INF/wjHtml", "/dwsurvey/WEB-INF/classes/conf/site"]
  54. EXPOSE 8080
  55. ENTRYPOINT [ "/docker-entry.sh" ]