xref: /OpenGrok/Dockerfile (revision 92d5925c150b65a12ef5b615e4d49486e7b43302)
1d016a90bSVladimir Kotal# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
26670a14aSVladimir Kotal
3944a6b32SAdam HornáčekFROM ubuntu:bionic as build
4944a6b32SAdam Hornáček
5*92d5925cSVladimir KotalRUN apt-get update && apt-get install -y maven python3 python3-venv
6944a6b32SAdam Hornáček
7944a6b32SAdam Hornáček# Create a first layer to cache the "Maven World" in the local repository.
8944a6b32SAdam Hornáček# Incremental docker builds will always resume after that, unless you update the pom
9944a6b32SAdam HornáčekWORKDIR /mvn
10944a6b32SAdam HornáčekCOPY pom.xml /mvn/
11944a6b32SAdam HornáčekCOPY opengrok-indexer/pom.xml /mvn/opengrok-indexer/
12944a6b32SAdam HornáčekCOPY opengrok-web/pom.xml /mvn/opengrok-web/
13944a6b32SAdam HornáčekCOPY plugins/pom.xml /mvn/plugins/
14944a6b32SAdam HornáčekCOPY suggester/pom.xml /mvn/suggester/
15944a6b32SAdam Hornáček
16944a6b32SAdam Hornáček# distribution and opengrok-tools do not have dependencies to cache
17944a6b32SAdam HornáčekRUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml
18944a6b32SAdam HornáčekRUN sed -i 's:<module>opengrok-tools</module>::g' /mvn/pom.xml
19944a6b32SAdam Hornáček
20944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-indexer/target/jflex-sources
21944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-web/src/main/webapp
22944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-tt.txt /mvn/opengrok-indexer/jflex-tt.txt
23944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-tt-end.txt /mvn/opengrok-indexer/jflex-tt-end.txt
24944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-code.txt /mvn/opengrok-indexer/jflex-code.txt
25944a6b32SAdam HornáčekCOPY opengrok-indexer/jflex-code-end.txt /mvn/opengrok-indexer/jflex-code-end.txt
26944a6b32SAdam HornáčekRUN mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && 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
36944a6b32SAdam HornáčekRUN cp distribution/target/*.tar.gz /opengrok.tar.gz
376670a14aSVladimir Kotal
38841e93e3SVladimir KotalFROM tomcat:9-jdk11
39944a6b32SAdam HornáčekLABEL maintainer="opengrok-dev@yahoogroups.com"
406670a14aSVladimir Kotal
416670a14aSVladimir Kotal# install dependencies and Python tools
42d016a90bSVladimir KotalRUN apt-get update && \
43d016a90bSVladimir Kotal    apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip python3-venv
446670a14aSVladimir Kotal
456670a14aSVladimir Kotal# compile and install universal-ctags
46d016a90bSVladimir KotalRUN apt-get install -y pkg-config autoconf build-essential && \
47d016a90bSVladimir Kotal    git clone https://github.com/universal-ctags/ctags /root/ctags && \
486670a14aSVladimir Kotal    cd /root/ctags && ./autogen.sh && ./configure && make && make install && \
49d016a90bSVladimir Kotal    apt-get remove -y autoconf build-essential && \
50d016a90bSVladimir Kotal    apt-get -y autoremove && apt-get -y autoclean && \
516670a14aSVladimir Kotal    cd /root && rm -rf /root/ctags
526670a14aSVladimir Kotal
53944a6b32SAdam Hornáček# prepare OpenGrok binaries and directories
54944a6b32SAdam HornáčekCOPY --from=build opengrok.tar.gz /opengrok.tar.gz
55944a6b32SAdam HornáčekRUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
56944a6b32SAdam Hornáček    tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \
57944a6b32SAdam Hornáček    rm -f /opengrok.tar.gz
58944a6b32SAdam Hornáček
59944a6b32SAdam HornáčekRUN python3 -m pip install /opengrok/tools/opengrok-tools*
60944a6b32SAdam Hornáček
616670a14aSVladimir Kotal# environment variables
626670a14aSVladimir KotalENV SRC_ROOT /opengrok/src
636670a14aSVladimir KotalENV DATA_ROOT /opengrok/data
646670a14aSVladimir KotalENV OPENGROK_WEBAPP_CONTEXT /
656670a14aSVladimir KotalENV OPENGROK_TOMCAT_BASE /usr/local/tomcat
666670a14aSVladimir KotalENV CATALINA_HOME /usr/local/tomcat
676670a14aSVladimir KotalENV CATALINA_BASE /usr/local/tomcat
686670a14aSVladimir KotalENV CATALINA_TMPDIR /usr/local/tomcat/temp
69ddb2897eSKryštof TulingerENV PATH $CATALINA_HOME/bin:$PATH
70841e93e3SVladimir Kotal# ENV JRE_HOME /usr
716670a14aSVladimir KotalENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
726670a14aSVladimir Kotal
736670a14aSVladimir Kotal# custom deployment to / with redirect from /source
746670a14aSVladimir KotalRUN rm -rf /usr/local/tomcat/webapps/* && \
753185e592SVladimir Kotal    opengrok-deploy -c /opengrok/etc/configuration.xml \
763185e592SVladimir Kotal        /opengrok/lib/source.war /usr/local/tomcat/webapps/ROOT.war && \
776670a14aSVladimir Kotal    mkdir "/usr/local/tomcat/webapps/source" && \
786670a14aSVladimir Kotal    echo '<% response.sendRedirect("/"); %>' > "/usr/local/tomcat/webapps/source/index.jsp"
796670a14aSVladimir Kotal
806670a14aSVladimir Kotal# disable all file logging
816670a14aSVladimir KotalADD docker/logging.properties /usr/local/tomcat/conf/logging.properties
826670a14aSVladimir KotalRUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml
836670a14aSVladimir Kotal
846670a14aSVladimir Kotal# add our scripts
856670a14aSVladimir KotalADD docker /scripts
866670a14aSVladimir KotalRUN chmod -R +x /scripts
876670a14aSVladimir Kotal
886670a14aSVladimir Kotal# run
896670a14aSVladimir KotalWORKDIR $CATALINA_HOME
906670a14aSVladimir KotalEXPOSE 8080
916670a14aSVladimir KotalCMD ["/scripts/start.sh"]
92