1d016a90bSVladimir Kotal# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. 2d051e170SChris Fraire# Portions Copyright (c) 2020, Chris Fraire <cfraire@me.com>. 36670a14aSVladimir Kotal 4944a6b32SAdam HornáčekFROM ubuntu:bionic as build 5944a6b32SAdam Hornáček 692d5925cSVladimir KotalRUN apt-get update && apt-get install -y maven python3 python3-venv 7944a6b32SAdam Hornáček 8944a6b32SAdam Hornáček# Create a first layer to cache the "Maven World" in the local repository. 9944a6b32SAdam Hornáček# Incremental docker builds will always resume after that, unless you update the pom 10944a6b32SAdam HornáčekWORKDIR /mvn 11944a6b32SAdam HornáčekCOPY pom.xml /mvn/ 12944a6b32SAdam HornáčekCOPY opengrok-indexer/pom.xml /mvn/opengrok-indexer/ 13944a6b32SAdam HornáčekCOPY opengrok-web/pom.xml /mvn/opengrok-web/ 14944a6b32SAdam HornáčekCOPY plugins/pom.xml /mvn/plugins/ 15944a6b32SAdam HornáčekCOPY suggester/pom.xml /mvn/suggester/ 16944a6b32SAdam Hornáček 17944a6b32SAdam Hornáček# distribution and opengrok-tools do not have dependencies to cache 18944a6b32SAdam HornáčekRUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml 19*2d57dc69SVladimir KotalRUN sed -i 's:<module>tools</module>::g' /mvn/pom.xml 20944a6b32SAdam Hornáček 21944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-indexer/target/jflex-sources 22944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-web/src/main/webapp 23944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml 24944a6b32SAdam Hornáček 25944a6b32SAdam Hornáček# dummy build to cache the dependencies 26944a6b32SAdam HornáčekRUN mvn -DskipTests -Dcheckstyle.skip -Dmaven.antrun.skip package 27944a6b32SAdam Hornáček 28944a6b32SAdam Hornáček# build the project 296670a14aSVladimir KotalCOPY ./ /opengrok-source 306670a14aSVladimir KotalWORKDIR /opengrok-source 316670a14aSVladimir Kotal 32944a6b32SAdam HornáčekRUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package 33579ed530SVladimir KotalRUN cp `ls -t distribution/target/*.tar.gz | head -1` /opengrok.tar.gz 346670a14aSVladimir Kotal 35841e93e3SVladimir KotalFROM tomcat:9-jdk11 364b66e81fSVladimir KotalLABEL maintainer="https://github.com/oracle/opengrok" 376670a14aSVladimir Kotal 386670a14aSVladimir Kotal# install dependencies and Python tools 39d016a90bSVladimir KotalRUN apt-get update && \ 40d016a90bSVladimir Kotal apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip python3-venv 416670a14aSVladimir Kotal 426670a14aSVladimir Kotal# compile and install universal-ctags 43d016a90bSVladimir KotalRUN apt-get install -y pkg-config autoconf build-essential && \ 44d016a90bSVladimir Kotal git clone https://github.com/universal-ctags/ctags /root/ctags && \ 456670a14aSVladimir Kotal cd /root/ctags && ./autogen.sh && ./configure && make && make install && \ 46d016a90bSVladimir Kotal apt-get remove -y autoconf build-essential && \ 47d016a90bSVladimir Kotal apt-get -y autoremove && apt-get -y autoclean && \ 486670a14aSVladimir Kotal cd /root && rm -rf /root/ctags 496670a14aSVladimir Kotal 50944a6b32SAdam Hornáček# prepare OpenGrok binaries and directories 51944a6b32SAdam HornáčekCOPY --from=build opengrok.tar.gz /opengrok.tar.gz 52944a6b32SAdam HornáčekRUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \ 53944a6b32SAdam Hornáček tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \ 54944a6b32SAdam Hornáček rm -f /opengrok.tar.gz 55944a6b32SAdam Hornáček 56944a6b32SAdam HornáčekRUN python3 -m pip install /opengrok/tools/opengrok-tools* 57944a6b32SAdam Hornáček 586670a14aSVladimir Kotal# environment variables 596670a14aSVladimir KotalENV SRC_ROOT /opengrok/src 606670a14aSVladimir KotalENV DATA_ROOT /opengrok/data 610f145a68STim SchumacherENV URL_ROOT / 626670a14aSVladimir KotalENV CATALINA_HOME /usr/local/tomcat 636670a14aSVladimir KotalENV CATALINA_BASE /usr/local/tomcat 646670a14aSVladimir KotalENV CATALINA_TMPDIR /usr/local/tomcat/temp 65ddb2897eSKryštof TulingerENV PATH $CATALINA_HOME/bin:$PATH 666670a14aSVladimir KotalENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar 676670a14aSVladimir Kotal 686670a14aSVladimir Kotal# disable all file logging 696670a14aSVladimir KotalADD docker/logging.properties /usr/local/tomcat/conf/logging.properties 706670a14aSVladimir KotalRUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml 716670a14aSVladimir Kotal 726670a14aSVladimir Kotal# add our scripts 736670a14aSVladimir KotalADD docker /scripts 746670a14aSVladimir KotalRUN chmod -R +x /scripts 756670a14aSVladimir Kotal 766670a14aSVladimir Kotal# run 776670a14aSVladimir KotalWORKDIR $CATALINA_HOME 786670a14aSVladimir KotalEXPOSE 8080 796670a14aSVladimir KotalCMD ["/scripts/start.sh"] 80