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 61ca9c879SAdam Hornacek# hadolint ignore=DL3008 71ca9c879SAdam HornacekRUN apt-get update && apt-get install --no-install-recommends -y maven python3 python3-venv && \ 81ca9c879SAdam Hornacek apt-get clean && \ 91ca9c879SAdam Hornacek rm -rf /var/lib/apt/lists/* 10944a6b32SAdam Hornáček 11944a6b32SAdam Hornáček# Create a first layer to cache the "Maven World" in the local repository. 12944a6b32SAdam Hornáček# Incremental docker builds will always resume after that, unless you update the pom 13944a6b32SAdam HornáčekWORKDIR /mvn 14944a6b32SAdam HornáčekCOPY pom.xml /mvn/ 15944a6b32SAdam HornáčekCOPY opengrok-indexer/pom.xml /mvn/opengrok-indexer/ 16944a6b32SAdam HornáčekCOPY opengrok-web/pom.xml /mvn/opengrok-web/ 17944a6b32SAdam HornáčekCOPY plugins/pom.xml /mvn/plugins/ 18944a6b32SAdam HornáčekCOPY suggester/pom.xml /mvn/suggester/ 19944a6b32SAdam Hornáček 2033aeed48SVladimir Kotal# distribution and tools do not have dependencies to cache 211ca9c879SAdam HornacekRUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml && \ 221ca9c879SAdam Hornacek sed -i 's:<module>tools</module>::g' /mvn/pom.xml && \ 231ca9c879SAdam Hornacek mkdir -p /mvn/opengrok-indexer/target/jflex-sources && \ 241ca9c879SAdam Hornacek mkdir -p /mvn/opengrok-web/src/main/webapp/js && \ 251ca9c879SAdam Hornacek mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && \ 261ca9c879SAdam Hornacek touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml 27944a6b32SAdam Hornáček 28944a6b32SAdam Hornáček# dummy build to cache the dependencies 29944a6b32SAdam HornáčekRUN mvn -DskipTests -Dcheckstyle.skip -Dmaven.antrun.skip package 30944a6b32SAdam Hornáček 31944a6b32SAdam Hornáček# build the project 326670a14aSVladimir KotalCOPY ./ /opengrok-source 336670a14aSVladimir KotalWORKDIR /opengrok-source 346670a14aSVladimir Kotal 35944a6b32SAdam HornáčekRUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package 361ca9c879SAdam Hornacek# hadolint ignore=SC2012,DL4006 37579ed530SVladimir KotalRUN cp `ls -t distribution/target/*.tar.gz | head -1` /opengrok.tar.gz 386670a14aSVladimir Kotal 39*85ee3da3SVladimir Kotal# Store the version in a file so that the tools can report it. 40*85ee3da3SVladimir KotalRUN mvn help:evaluate -Dexpression=project.version -q -DforceStdout > /mvn/VERSION 41*85ee3da3SVladimir Kotal 42aa6abf42SAdam HornacekFROM tomcat:10-jdk11 434b66e81fSVladimir KotalLABEL maintainer="https://github.com/oracle/opengrok" 446670a14aSVladimir Kotal 456670a14aSVladimir Kotal# install dependencies and Python tools 461ca9c879SAdam Hornacek# hadolint ignore=DL3008,DL3009 47d016a90bSVladimir KotalRUN apt-get update && \ 481ca9c879SAdam Hornacek apt-get install --no-install-recommends -y git subversion mercurial unzip inotify-tools python3 python3-pip \ 491ca9c879SAdam Hornacek python3-venv python3-setuptools 506670a14aSVladimir Kotal 516670a14aSVladimir Kotal# compile and install universal-ctags 521ca9c879SAdam Hornacek# hadolint ignore=DL3003,DL3008 531ca9c879SAdam HornacekRUN apt-get install --no-install-recommends -y pkg-config automake build-essential && \ 54d016a90bSVladimir Kotal git clone https://github.com/universal-ctags/ctags /root/ctags && \ 556670a14aSVladimir Kotal cd /root/ctags && ./autogen.sh && ./configure && make && make install && \ 561ca9c879SAdam Hornacek apt-get remove -y automake build-essential && \ 57d016a90bSVladimir Kotal apt-get -y autoremove && apt-get -y autoclean && \ 581ca9c879SAdam Hornacek cd /root && rm -rf /root/ctags && \ 591ca9c879SAdam Hornacek apt-get clean && \ 601ca9c879SAdam Hornacek rm -rf /var/lib/apt/lists/* 616670a14aSVladimir Kotal 62944a6b32SAdam Hornáček# prepare OpenGrok binaries and directories 631ca9c879SAdam Hornacek# hadolint ignore=DL3010 64944a6b32SAdam HornáčekCOPY --from=build opengrok.tar.gz /opengrok.tar.gz 651ca9c879SAdam Hornacek# hadolint ignore=DL3013 66944a6b32SAdam HornáčekRUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \ 67944a6b32SAdam Hornáček tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \ 681ca9c879SAdam Hornacek rm -f /opengrok.tar.gz && \ 691ca9c879SAdam Hornacek python3 -m pip install --no-cache-dir /opengrok/tools/opengrok-tools* && \ 701ca9c879SAdam Hornacek python3 -m pip install --no-cache-dir Flask Flask-HTTPAuth waitress # for /reindex REST endpoint handled by start.py 71f1835fddSVladimir Kotal 72*85ee3da3SVladimir KotalCOPY --from=build /mvn/VERSION /opengrok/VERSION 73*85ee3da3SVladimir Kotal 746670a14aSVladimir Kotal# environment variables 756670a14aSVladimir KotalENV SRC_ROOT /opengrok/src 766670a14aSVladimir KotalENV DATA_ROOT /opengrok/data 770f145a68STim SchumacherENV URL_ROOT / 786670a14aSVladimir KotalENV CATALINA_HOME /usr/local/tomcat 796670a14aSVladimir KotalENV CATALINA_BASE /usr/local/tomcat 806670a14aSVladimir KotalENV CATALINA_TMPDIR /usr/local/tomcat/temp 81ddb2897eSKryštof TulingerENV PATH $CATALINA_HOME/bin:$PATH 826670a14aSVladimir KotalENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar 836670a14aSVladimir Kotal 846670a14aSVladimir Kotal# disable all file logging 851ca9c879SAdam HornacekCOPY docker/logging.properties /usr/local/tomcat/conf/logging.properties 866670a14aSVladimir KotalRUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml 876670a14aSVladimir Kotal 886670a14aSVladimir Kotal# add our scripts 891ca9c879SAdam HornacekCOPY docker /scripts 906670a14aSVladimir KotalRUN chmod -R +x /scripts 916670a14aSVladimir Kotal 926670a14aSVladimir Kotal# run 936670a14aSVladimir KotalWORKDIR $CATALINA_HOME 946670a14aSVladimir KotalEXPOSE 8080 95b2d29daeSVladimir KotalCMD ["/scripts/start.py"] 96