Skip to content

Commit f378a5d

Browse files
timschumiVladimir Kotal
authored andcommitted
docker: Move deployment to startup and adapt for custom path
1 parent b714910 commit f378a5d

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

Dockerfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ ENV CATALINA_TMPDIR /usr/local/tomcat/temp
6666
ENV PATH $CATALINA_HOME/bin:$PATH
6767
ENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
6868

69-
# custom deployment to / with redirect from /source
70-
RUN rm -rf /usr/local/tomcat/webapps/* && \
71-
opengrok-deploy -c /opengrok/etc/configuration.xml \
72-
/opengrok/lib/source.war /usr/local/tomcat/webapps/ROOT.war && \
73-
mkdir "/usr/local/tomcat/webapps/source" && \
74-
echo '<% response.sendRedirect("/"); %>' > "/usr/local/tomcat/webapps/source/index.jsp"
75-
7669
# disable all file logging
7770
ADD docker/logging.properties /usr/local/tomcat/conf/logging.properties
7871
RUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml

docker/index.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
LOCKFILE=/var/run/opengrok-indexer
4-
URI="http://localhost:8080"
4+
URI="http://localhost:8080/${OPENGROK_WEBAPP_CONTEXT#/}"
55
# $OPS can be overwritten by environment variable
66
OPS=${INDEXER_FLAGS:='-H -P -S -G'}
77

docker/start.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@ if [ -z "$REINDEX" ]; then
55
REINDEX=10
66
fi
77

8+
if [ "${OPENGROK_WEBAPP_CONTEXT}" = "/" ]; then
9+
WAR_NAME="ROOT.war"
10+
else
11+
WAR_NAME="${OPENGROK_WEBAPP_CONTEXT#/}.war"
12+
fi
13+
14+
if [ ! -f "/usr/local/tomcat/webapps/${WAR_NAME}" ]; then
15+
date +"%F %T Deployment path changed. Redeploying..."
16+
17+
# Delete old deployment and (re)deploy
18+
rm -rf /usr/local/tomcat/webapps/*
19+
opengrok-deploy -c /opengrok/etc/configuration.xml \
20+
/opengrok/lib/source.war /usr/local/tomcat/webapps/${WAR_NAME}
21+
22+
# Set up redirect from /source
23+
mkdir "/usr/local/tomcat/webapps/source"
24+
echo "<% response.sendRedirect(\"${OPENGROK_WEBAPP_CONTEXT}\"); %>" > "/usr/local/tomcat/webapps/source/index.jsp"
25+
fi
26+
827
indexer(){
928
# Wait for Tomcat startup.
1029
date +"%F %T Waiting for Tomcat startup..."
11-
while [ "`curl --silent --write-out '%{response_code}' -o /dev/null 'http://localhost:8080/'`" == "000" ]; do
30+
while [ "`curl --silent --write-out '%{response_code}' -o /dev/null 'http://localhost:8080/${OPENGROK_WEBAPP_CONTEXT#/}'`" == "000" ]; do
1231
sleep 1;
1332
done
1433
date +"%F %T Startup finished"

0 commit comments

Comments
 (0)