From 6b032d9c05c72cd1a7f4f6ba62e5074bce4b86f2 Mon Sep 17 00:00:00 2001 From: Joonas Hiltunen Date: Thu, 29 Jan 2026 09:52:12 +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 fe92006..2fcce60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,17 +16,25 @@ RUN mvn clean package spring-boot:repackage -Pprod # distributed docker image FROM eclipse-temurin:25.0.1_8-jre +# Application Insights version +ARG APPINSIGHTS_VERSION=3.7.7 + # expose server port EXPOSE 8080 # download script for reading docker secrets ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /app/scripts/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-auth/applicationinsights-agent.jar +COPY --chmod=755 ./applicationinsights.json /usr/src/jore4-auth/applicationinsights.json + # copy over compiled jar COPY --from=builder /build/target/*.jar /usr/src/jore4-auth/auth-backend.jar # read docker secrets into environment variables and run application -CMD ["/bin/bash", "-c", "source /app/scripts/read-secrets.sh && java -jar /usr/src/jore4-auth/auth-backend.jar"] +CMD ["/bin/bash", "-c", "source /app/scripts/read-secrets.sh && java -javaagent:/usr/src/jore4-auth/applicationinsights-agent.jar -jar /usr/src/jore4-auth/auth-backend.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..63df862 --- /dev/null +++ b/applicationinsights.json @@ -0,0 +1,5 @@ +{ + "role": { + "name": "jore4-auth" + } +}