Skip to content

Commit a8c364d

Browse files
committed
the docker image can be successfully built
1 parent bfe8811 commit a8c364d

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed

docker.logging.properties

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2017 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
handlers = java.util.logging.ConsoleHandler
19+
20+
.handlers = java.util.logging.ConsoleHandler
21+
22+
############################################################
23+
# Handler specific properties.
24+
# Describes specific configuration info for Handlers.
25+
############################################################
26+
27+
java.util.logging.ConsoleHandler.level = FINE
28+
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
29+
30+
############################################################
31+
# Facility specific properties.
32+
# Provides extra control for each logger.
33+
############################################################
34+
35+
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
36+
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.ConsoleHandler
37+
38+
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
39+
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = java.util.logging.ConsoleHandler
40+
41+
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
42+
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = java.util.logging.ConsoleHandler

dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM maven:latest as builder
2+
3+
COPY ./ /opengrok-source
4+
WORKDIR /opengrok-source
5+
6+
RUN apt-get update && apt-get install -y python3 python3-venv
7+
RUN mvn -f pom.xml clean package -DskipTests=true
8+
9+
RUN cp `ls -t distribution/target/*.tar.gz | head -n1 |awk '{printf("%s",$0)}'` /opengrok.tar.gz
10+
11+
FROM tomcat:9-jre8
12+
LABEL maintainer "[email protected]"
13+
14+
# prepare OpenGrok binaries and directories
15+
COPY --from=builder opengrok.tar.gz /opengrok.tar.gz
16+
RUN mkdir -p /opengrok /var/opengrok/etc /opengrok/data /opengrok/src && \
17+
tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \
18+
rm -f /opengrok.tar.gz
19+
20+
# install dependencies
21+
RUN apt-get update && apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip && \
22+
python3 -m pip install /opengrok/tools/opengrok-tools*
23+
# compile and install universal-ctags
24+
RUN apt-get install -y pkg-config autoconf build-essential && git clone https://github.com/universal-ctags/ctags /root/ctags && \
25+
cd /root/ctags && ./autogen.sh && ./configure && make && make install && \
26+
apt-get remove -y autoconf build-essential && apt-get -y autoremove && apt-get -y autoclean && \
27+
cd /root && rm -rf /root/ctags
28+
29+
# environment variables
30+
ENV SRC_ROOT /opengrok/src
31+
ENV DATA_ROOT /opengrok/data
32+
ENV OPENGROK_WEBAPP_CONTEXT /
33+
ENV OPENGROK_TOMCAT_BASE /usr/local/tomcat
34+
ENV CATALINA_HOME /usr/local/tomcat
35+
ENV PATH $CATALINA_HOME/bin:$PATH
36+
ENV CATALINA_BASE /usr/local/tomcat
37+
ENV CATALINA_HOME /usr/local/tomcat
38+
ENV CATALINA_TMPDIR /usr/local/tomcat/temp
39+
ENV JRE_HOME /usr
40+
ENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
41+
42+
43+
# custom deployment to / with redirect from /source
44+
RUN rm -rf /usr/local/tomcat/webapps/* && \
45+
opengrok-deploy /opengrok/lib/source.war /usr/local/tomcat/webapps/ROOT.war && \
46+
mkdir "/usr/local/tomcat/webapps/source" && \
47+
echo '<% response.sendRedirect("/"); %>' > "/usr/local/tomcat/webapps/source/index.jsp"
48+
49+
# disable all file logging
50+
ADD docker.logging.properties /usr/local/tomcat/conf/logging.properties
51+
RUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml
52+
53+
# add our scripts
54+
ADD scripts /scripts
55+
RUN chmod -R +x /scripts
56+
57+
# run
58+
WORKDIR $CATALINA_HOME
59+
EXPOSE 8080
60+
CMD ["/scripts/start.sh"]

scripts/index.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
LOCKFILE=/var/run/opengrok-indexer
4+
URI="http://localhost:8080"
5+
6+
if [ -f "$LOCKFILE" ]; then
7+
date +"%F %T Indexer still locked, skipping indexing"
8+
exit 1
9+
fi
10+
11+
touch $LOCKFILE
12+
13+
if [ -z $NOMIRROR ]; then
14+
date +"%F %T Mirroring starting"
15+
opengrok-mirror --all --uri "$URI"
16+
date +"%F %T Mirroring finished"
17+
fi
18+
19+
date +"%F %T Indexing starting"
20+
opengrok-indexer \
21+
-a /opengrok/lib/opengrok.jar -- \
22+
-s /opengrok/src \
23+
-d /opengrok/data \
24+
-H -P -S -G \
25+
--leadingWildCards on \
26+
-W /var/opengrok/etc/configuration.xml \
27+
-U "$URI" \
28+
$INDEXER_OPT "$@"
29+
date +"%F %T Indexing finished"
30+
31+
rm -f $LOCKFILE

scripts/start.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# default period for reindexing (in minutes)
4+
if [ -z "$REINDEX" ]; then
5+
REINDEX=10
6+
fi
7+
8+
indexer(){
9+
# Wait for Tomcat startup.
10+
date +"%F %T Waiting for Tomcat startup..."
11+
while [ "`curl --silent --write-out '%{response_code}' -o /dev/null 'http://localhost:8080/'`" == "000" ]; do
12+
sleep 1;
13+
done
14+
date +"%F %T Startup finished"
15+
16+
if [[ ! -d /opengrok/data/index ]]; then
17+
# Populate the webapp with bare configuration.
18+
BODY_INCLUDE_FILE="/opengrok/data/body_include"
19+
if [[ -f $BODY_INCLUDE_FILE ]]; then
20+
mv "$BODY_INCLUDE_FILE" "$BODY_INCLUDE_FILE.orig"
21+
fi
22+
echo '<p><h1>Waiting on the initial reindex to finish.. Stay tuned !</h1></p>' > "$BODY_INCLUDE_FILE"
23+
/scripts/index.sh --noIndex
24+
rm -f "$BODY_INCLUDE_FILE"
25+
if [[ -f $BODY_INCLUDE_FILE.orig ]]; then
26+
mv "$BODY_INCLUDE_FILE.orig" "$BODY_INCLUDE_FILE"
27+
fi
28+
29+
# Perform initial indexing.
30+
NOMIRROR=1 /scripts/index.sh
31+
date +"%F %T Initial reindex finished"
32+
fi
33+
34+
# Continue to index every $REINDEX minutes.
35+
if [ "$REINDEX" == "0" ]; then
36+
date +"%F %T Automatic reindexing disabled"
37+
return
38+
else
39+
date +"%F %T Automatic reindexing in $REINDEX minutes..."
40+
fi
41+
while true; do
42+
sleep `expr 60 \* $REINDEX`
43+
/scripts/index.sh
44+
done
45+
}
46+
47+
# Start all necessary services.
48+
indexer &
49+
catalina.sh run

0 commit comments

Comments
 (0)