From bfd361b73afb4a397c127886a69b06bedc9502bc Mon Sep 17 00:00:00 2001 From: Joonas Hiltunen Date: Thu, 29 Jan 2026 09:59:44 +0200 Subject: [PATCH] Enable Application Insights --- Dockerfile | 10 +++++++++- applicationinsights.json | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 applicationinsights.json diff --git a/Dockerfile b/Dockerfile index 70cb8c3..246434d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,9 @@ RUN mvn -Pprod -DskipTests=true clean package spring-boot:repackage FROM eclipse-temurin:25.0.1_8-jre +# Application Insights version +ARG APPINSIGHTS_VERSION=3.7.7 + RUN apt-get update && apt-get install -y curl # expose server port @@ -24,6 +27,11 @@ EXPOSE 8080 # download script for reading Docker secrets ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /tmp/read-secrets.sh +# Connection string is provided as env in Kubernetes by secrets manager +# it should not be provided for other environments (local etc) +ADD --chmod=755 https://github.com/microsoft/ApplicationInsights-Java/releases/download/${APPINSIGHTS_VERSION}/applicationinsights-agent-${APPINSIGHTS_VERSION}.jar /usr/src/jore4-timetables/applicationinsights-agent.jar +COPY --chmod=755 ./applicationinsights.json /usr/src/jore4-timetables/applicationinsights.json + # copy over helper scripts COPY --chmod=755 ./script/build-jdbc-urls.sh /tmp/ @@ -31,7 +39,7 @@ COPY --chmod=755 ./script/build-jdbc-urls.sh /tmp/ COPY --from=builder /build/target/*.jar /usr/src/jore4-timetables/jore4-timetables.jar # read Docker secrets into environment variables and run application -CMD ["/bin/bash", "-c", "source /tmp/read-secrets.sh && source /tmp/build-jdbc-urls.sh && java -jar /usr/src/jore4-timetables/jore4-timetables.jar"] +CMD ["/bin/bash", "-c", "source /tmp/read-secrets.sh && source /tmp/build-jdbc-urls.sh && java -javaagent:/usr/src/jore4-timetables/applicationinsights-agent.jar -jar /usr/src/jore4-timetables/jore4-timetables.jar"] HEALTHCHECK --interval=1m --timeout=5s \ CMD curl --fail http://localhost:8080/actuator/health diff --git a/applicationinsights.json b/applicationinsights.json new file mode 100644 index 0000000..28c4f28 --- /dev/null +++ b/applicationinsights.json @@ -0,0 +1,5 @@ +{ + "role": { + "name": "jore4-timetables" + } +}