Skip to content

Commit

Permalink
#278: working nicely!
Browse files Browse the repository at this point in the history
  • Loading branch information
lsulak committed Sep 26, 2024
1 parent 9bf1d92 commit ed619ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ docker build -t absaoss/atum-service:latest --progress=plain --no-cache \

# If you want to run it against AWS, you need to add AWS related credentials into the docker container, possibly via
# environment variables; but you can also run it against your a local Postgres DB (in host or another Docker container).
docker run /absolute/path/resource.conf:/opt/config/resource.conf \
docker run -v /absolute/path/resource.conf:/opt/config/resource.conf \
-e AWS_ACCESS_KEY_ID="abc" -e AWS_SECRET_ACCESS_KEY="def" -e AWS_SESSION_TOKEN="xyz" \
-p 8080:8080 -p 8443:8443 absaoss/atum-service:latest

Expand Down
18 changes: 16 additions & 2 deletions server/docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@
CUSTOM_CONFIG_LOCATION="/opt/config/resource.conf"
JAR_LOCATION="/opt/app/atum-service.jar"

# Why `exec` - mostly for a correct termination signal handling & finishing the application.
#
# Explanation: The exec command replaces the shell process with the Java process, so the Java process (our application)
# becomes the main process (PID 1) in the container. Docker automatically sends termination signals
# (SIGTERM, SIGINT, etc.) to PID 1, so the Java process will directly receive the signals and can terminate cleanly.
#
# When you define ENTRYPOINT in a Dockerfile and it points to a shell script, as it is in our case, what actually
# happens is that the shell starts first, executes the script, and then runs whatever commands are inside that script.
# For example, without exec, the process flow looks like this:
# 1. Docker starts the container, and the shell process (/bin/sh) is launched.
# 2. The shell process begins executing this `docker_entrypoint.sh` script.
# 3. Inside the script, if you run java, the shell spawns a child process to run the java command, while the shell
# process remains the parent process (still PID 1). But what we want is our Java to have PID 1 to receive
# termination signals.
if [ -f "${CUSTOM_CONFIG_LOCATION}" ]; then
echo "Running with custom config"
java -Dconfig.file="${CUSTOM_CONFIG_LOCATION}" -jar "${JAR_LOCATION}"
exec java -Dconfig.file="${CUSTOM_CONFIG_LOCATION}" -jar "${JAR_LOCATION}"
else
echo "Running with default config"
java -jar "${JAR_LOCATION}"
exec java -jar "${JAR_LOCATION}"
fi

0 comments on commit ed619ec

Please sign in to comment.