echo -e "\nBuilding the docker image and running the containers..\n"
sudo docker --version || handle_error "Docker was not found!"3
(sudo mkdir -p "$HOME"/tmp/config && sudo cp ./src/main/resources/application.yml "$HOME"/tmp/config)||true# This also replaces an existing "application.yml".
sudo mkdir -p "$HOME"/logs ||true
# Run in "detached mode" -d (in the background).
(sudo docker compose up --build -d &&echo -e "\nThe pdf_aggregation_statistics docker-container started running.\n")|| handle_error "Could not build and/or run the 'pdf_aggregation_statistics' docker container!"4
sudo docker ps -a || handle_error "Could not get the status of docker-containers!"6# Using -a to get the status of failed containers as well.
echo -e "\n\nGetting the logs of docker-container \"pdf_aggregation_statistics\":\n"
sudo docker logs "$(sudo docker ps -aqf "name=^pdf_aggregation_statistics$")"|| handle_error "Could not get the logs of docker-container \"pdf_aggregation_statistics\"!"7# Using "regex anchors" to avoid false-positives. Works even if the container is not running, thus showing the error-log.
fi
else
exportPATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH# Make sure the gradle is still accessible (it usually isn't without the "export").