Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds docker entrypoint that will check/warn for missing configurations #31

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FROM rockylinux:8
COPY rpm/target/rpm/com.teragrep-lsh_01/RPMS/noarch/com.teragrep-lsh_01-*.rpm /lsh_01.rpm
RUN dnf install -y /lsh_01.rpm && rm -f /lsh_01.rpm && dnf clean all
USER srv-lsh_01
ENTRYPOINT ["/usr/bin/java"]
CMD ["-Dproperties.file=/config/config.properties", "-Dlog4j2.configurationFile=file:/config/log4j2.xml", "-jar", "/opt/teragrep/lsh_01/share/lsh_01.jar"]
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
4 changes: 3 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Run maven on java 11

Mount configurations to `/config/` and run.

Expected files are `/config/config.properties` and `/config/log4j2.xml`
Configuration is expected to be in `/config/config.properties`

Custom `log4j2.xml` can be provided by placing it in `/config/log4j2.xml`, otherwise default settings will be used.

For example

Expand Down
14 changes: 14 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
if [ ! -f /config/config.properties ]; then
echo "ERROR: Missing '/config/config.properties', refusing to continue";
exit 1;
fi;

if [ -f /config/log4j2.xml ]; then
LOG4J_FILE="/config/log4j2.xml";
else
echo "INFO: Missing '/config/log4j2.xml', using default logger config";
LOG4J_FILE="/opt/teragrep/lsh_01/etc/log4j2.xml";
fi;

exec /usr/bin/java -Dproperties.file=/config/config.properties -Dlog4j2.configurationFile=file:"${LOG4J_FILE}" -jar /opt/teragrep/lsh_01/share/lsh_01.jar
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<exclude>rpm/src/main/resources/*</exclude>
<!-- docker -->
<exclude>Dockerfile</exclude>
<exclude>docker-entrypoint.sh</exclude>
<!-- resources -->
<exclude>etc/config.properties</exclude>
<exclude>src/main/assembly/jar-with-dependencies.xml</exclude>
Expand Down