xref: /OpenGrok/Dockerfile (revision 944a6b32c7aa4e2ba04fe5f382862dea10e43871)
1*944a6b32SAdam Hornáček# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
26670a14aSVladimir Kotal
3*944a6b32SAdam HornáčekFROM ubuntu:bionic as build
4*944a6b32SAdam Hornáček
5*944a6b32SAdam HornáčekRUN apt-get update && apt-get install -y openjdk-8-jdk maven python3 python3-venv
6*944a6b32SAdam Hornáček
7*944a6b32SAdam Hornáček# Create a first layer to cache the "Maven World" in the local repository.
8*944a6b32SAdam Hornáček# Incremental docker builds will always resume after that, unless you update the pom
9*944a6b32SAdam HornáčekWORKDIR /mvn
10*944a6b32SAdam HornáčekCOPY pom.xml /mvn/
11*944a6b32SAdam HornáčekCOPY opengrok-indexer/pom.xml /mvn/opengrok-indexer/
12*944a6b32SAdam HornáčekCOPY opengrok-web/pom.xml /mvn/opengrok-web/
13*944a6b32SAdam HornáčekCOPY plugins/pom.xml /mvn/plugins/
14*944a6b32SAdam HornáčekCOPY suggester/pom.xml /mvn/suggester/
15*944a6b32SAdam Hornáček
16*944a6b32SAdam Hornáček# distribution and opengrok-tools do not have dependencies to cache
17*944a6b32SAdam HornáčekRUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml
18*944a6b32SAdam HornáčekRUN sed -i 's:<module>opengrok-tools</module>::g' /mvn/pom.xml
19*944a6b32SAdam Hornáček
20*944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-indexer/target/jflex-sources
21*944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-web/src/main/webapp
22*944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-tt.txt /mvn/opengrok-indexer/jflex-tt.txt
23*944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-tt-end.txt /mvn/opengrok-indexer/jflex-tt-end.txt
24*944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-code.txt /mvn/opengrok-indexer/jflex-code.txt
25*944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-code-end.txt /mvn/opengrok-indexer/jflex-code-end.txt
26*944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml
27*944a6b32SAdam Hornáček
28*944a6b32SAdam Hornáček# dummy build to cache the dependencies
29*944a6b32SAdam HornáčekRUN mvn -DskipTests -Dcheckstyle.skip -Dmaven.antrun.skip package
30*944a6b32SAdam Hornáček
31*944a6b32SAdam Hornáček# build the project
326670a14aSVladimir KotalCOPY ./ /opengrok-source
336670a14aSVladimir KotalWORKDIR /opengrok-source
346670a14aSVladimir Kotal
35*944a6b32SAdam HornáčekRUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package
36*944a6b32SAdam HornáčekRUN cp distribution/target/*.tar.gz /opengrok.tar.gz
376670a14aSVladimir Kotal
386670a14aSVladimir KotalFROM tomcat:9-jre8
39*944a6b32SAdam HornáčekLABEL maintainer="opengrok-dev@yahoogroups.com"
406670a14aSVladimir Kotal
416670a14aSVladimir Kotal# install dependencies and Python tools
42*944a6b32SAdam HornáčekRUN apt-get update && apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip python3-venv
436670a14aSVladimir Kotal
446670a14aSVladimir Kotal# compile and install universal-ctags
456670a14aSVladimir KotalRUN apt-get install -y pkg-config autoconf build-essential && git clone https://github.com/universal-ctags/ctags /root/ctags && \
466670a14aSVladimir Kotal    cd /root/ctags && ./autogen.sh && ./configure && make && make install && \
476670a14aSVladimir Kotal    apt-get remove -y autoconf build-essential && apt-get -y autoremove && apt-get -y autoclean && \
486670a14aSVladimir Kotal    cd /root && rm -rf /root/ctags
496670a14aSVladimir Kotal
50*944a6b32SAdam Hornáček# prepare OpenGrok binaries and directories
51*944a6b32SAdam HornáčekCOPY --from=build opengrok.tar.gz /opengrok.tar.gz
52*944a6b32SAdam HornáčekRUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
53*944a6b32SAdam Hornáček    tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \
54*944a6b32SAdam Hornáček    rm -f /opengrok.tar.gz
55*944a6b32SAdam Hornáček
56*944a6b32SAdam HornáčekRUN python3 -m pip install /opengrok/tools/opengrok-tools*
57*944a6b32SAdam Hornáček
586670a14aSVladimir Kotal# environment variables
596670a14aSVladimir KotalENV SRC_ROOT /opengrok/src
606670a14aSVladimir KotalENV DATA_ROOT /opengrok/data
616670a14aSVladimir KotalENV OPENGROK_WEBAPP_CONTEXT /
626670a14aSVladimir KotalENV OPENGROK_TOMCAT_BASE /usr/local/tomcat
636670a14aSVladimir KotalENV CATALINA_HOME /usr/local/tomcat
646670a14aSVladimir KotalENV CATALINA_BASE /usr/local/tomcat
656670a14aSVladimir KotalENV CATALINA_TMPDIR /usr/local/tomcat/temp
66ddb2897eSKryštof TulingerENV PATH $CATALINA_HOME/bin:$PATH
676670a14aSVladimir KotalENV JRE_HOME /usr
686670a14aSVladimir KotalENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
696670a14aSVladimir Kotal
706670a14aSVladimir Kotal# custom deployment to / with redirect from /source
716670a14aSVladimir KotalRUN rm -rf /usr/local/tomcat/webapps/* && \
723185e592SVladimir Kotal    opengrok-deploy -c /opengrok/etc/configuration.xml \
733185e592SVladimir Kotal        /opengrok/lib/source.war /usr/local/tomcat/webapps/ROOT.war && \
746670a14aSVladimir Kotal    mkdir "/usr/local/tomcat/webapps/source" && \
756670a14aSVladimir Kotal    echo '<% response.sendRedirect("/"); %>' > "/usr/local/tomcat/webapps/source/index.jsp"
766670a14aSVladimir Kotal
776670a14aSVladimir Kotal# disable all file logging
786670a14aSVladimir KotalADD docker/logging.properties /usr/local/tomcat/conf/logging.properties
796670a14aSVladimir KotalRUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml
806670a14aSVladimir Kotal
816670a14aSVladimir Kotal# add our scripts
826670a14aSVladimir KotalADD docker /scripts
836670a14aSVladimir KotalRUN chmod -R +x /scripts
846670a14aSVladimir Kotal
856670a14aSVladimir Kotal# run
866670a14aSVladimir KotalWORKDIR $CATALINA_HOME
876670a14aSVladimir KotalEXPOSE 8080
886670a14aSVladimir KotalCMD ["/scripts/start.sh"]
89