1# Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved. 2# Portions Copyright (c) 2020, Chris Fraire <cfraire@me.com>. 3 4FROM ubuntu:bionic as build 5 6# hadolint ignore=DL3008 7RUN apt-get update && apt-get install --no-install-recommends -y maven python3 python3-venv && \ 8 apt-get clean && \ 9 rm -rf /var/lib/apt/lists/* 10 11# Create a first layer to cache the "Maven World" in the local repository. 12# Incremental docker builds will always resume after that, unless you update the pom 13WORKDIR /mvn 14COPY pom.xml /mvn/ 15COPY opengrok-indexer/pom.xml /mvn/opengrok-indexer/ 16COPY opengrok-web/pom.xml /mvn/opengrok-web/ 17COPY plugins/pom.xml /mvn/plugins/ 18COPY suggester/pom.xml /mvn/suggester/ 19 20# distribution and tools do not have dependencies to cache 21RUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml && \ 22 sed -i 's:<module>tools</module>::g' /mvn/pom.xml && \ 23 mkdir -p /mvn/opengrok-indexer/target/jflex-sources && \ 24 mkdir -p /mvn/opengrok-web/src/main/webapp/js && \ 25 mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && \ 26 touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml 27 28# dummy build to cache the dependencies 29RUN mvn -DskipTests -Dcheckstyle.skip -Dmaven.antrun.skip package 30 31# build the project 32COPY ./ /opengrok-source 33WORKDIR /opengrok-source 34 35RUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package 36# hadolint ignore=SC2012,DL4006 37RUN cp `ls -t distribution/target/*.tar.gz | head -1` /opengrok.tar.gz 38 39# Store the version in a file so that the tools can report it. 40RUN mvn help:evaluate -Dexpression=project.version -q -DforceStdout > /mvn/VERSION 41 42FROM tomcat:10-jdk11 43LABEL maintainer="https://github.com/oracle/opengrok" 44 45# install dependencies and Python tools 46# hadolint ignore=DL3008,DL3009 47RUN apt-get update && \ 48 apt-get install --no-install-recommends -y git subversion mercurial unzip inotify-tools python3 python3-pip \ 49 python3-venv python3-setuptools 50 51# compile and install universal-ctags 52# hadolint ignore=DL3003,DL3008 53RUN apt-get install --no-install-recommends -y pkg-config automake build-essential && \ 54 git clone https://github.com/universal-ctags/ctags /root/ctags && \ 55 cd /root/ctags && ./autogen.sh && ./configure && make && make install && \ 56 apt-get remove -y automake build-essential && \ 57 apt-get -y autoremove && apt-get -y autoclean && \ 58 cd /root && rm -rf /root/ctags && \ 59 apt-get clean && \ 60 rm -rf /var/lib/apt/lists/* 61 62# prepare OpenGrok binaries and directories 63# hadolint ignore=DL3010 64COPY --from=build opengrok.tar.gz /opengrok.tar.gz 65# hadolint ignore=DL3013 66RUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \ 67 tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \ 68 rm -f /opengrok.tar.gz && \ 69 python3 -m pip install --no-cache-dir /opengrok/tools/opengrok-tools* && \ 70 python3 -m pip install --no-cache-dir Flask Flask-HTTPAuth waitress # for /reindex REST endpoint handled by start.py 71 72COPY --from=build /mvn/VERSION /opengrok/VERSION 73 74# environment variables 75ENV SRC_ROOT /opengrok/src 76ENV DATA_ROOT /opengrok/data 77ENV URL_ROOT / 78ENV CATALINA_HOME /usr/local/tomcat 79ENV CATALINA_BASE /usr/local/tomcat 80ENV CATALINA_TMPDIR /usr/local/tomcat/temp 81ENV PATH $CATALINA_HOME/bin:$PATH 82ENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar 83 84# disable all file logging 85COPY docker/logging.properties /usr/local/tomcat/conf/logging.properties 86RUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml 87 88# add our scripts 89COPY docker /scripts 90RUN chmod -R +x /scripts 91 92# run 93WORKDIR $CATALINA_HOME 94EXPOSE 8080 95CMD ["/scripts/start.py"] 96