Skip to content

Commit 85ee3da

Browse files
Vladimir Kotalahornace
authored andcommitted
report version on Docker container startup
1 parent 3c85781 commit 85ee3da

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ RUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package
3636
# hadolint ignore=SC2012,DL4006
3737
RUN cp `ls -t distribution/target/*.tar.gz | head -1` /opengrok.tar.gz
3838

39+
# Store the version in a file so that the tools can report it.
40+
RUN mvn help:evaluate -Dexpression=project.version -q -DforceStdout > /mvn/VERSION
41+
3942
FROM tomcat:10-jdk11
4043
LABEL maintainer="https://github.com/oracle/opengrok"
4144

@@ -66,6 +69,8 @@ RUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
6669
python3 -m pip install --no-cache-dir /opengrok/tools/opengrok-tools* && \
6770
python3 -m pip install --no-cache-dir Flask Flask-HTTPAuth waitress # for /reindex REST endpoint handled by start.py
6871

72+
COPY --from=build /mvn/VERSION /opengrok/VERSION
73+
6974
# environment variables
7075
ENV SRC_ROOT /opengrok/src
7176
ENV DATA_ROOT /opengrok/data

docker/start.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ def main():
467467

468468
logger = get_console_logger(get_class_basename(), log_level)
469469

470+
try:
471+
with open(os.path.join(OPENGROK_BASE_DIR, "VERSION"), "r") as f:
472+
version = f.read()
473+
logger.info("Running version {}".format(version))
474+
except Exception:
475+
pass
476+
470477
uri, url_root = set_url_root(logger, os.environ.get('URL_ROOT'))
471478
logger.debug("URL_ROOT = {}".format(url_root))
472479
logger.debug("URI = {}".format(uri))

0 commit comments

Comments
 (0)