Skip to content

Commit df5f46d

Browse files
Joonas HiltunenJontzii
authored andcommitted
Enable Application Insights
1 parent 5ce9ff3 commit df5f46d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,25 @@ RUN mvn clean package spring-boot:repackage -Pprod
1616
# distributed docker image
1717
FROM eclipse-temurin:25.0.1_8-jre
1818

19+
# Application Insights version
20+
ARG APPINSIGHTS_VERSION=3.7.7
21+
1922
# expose server port
2023
EXPOSE 8080
2124

2225
# download script for reading docker secrets
2326
ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /app/scripts/read-secrets.sh
2427

28+
# Connection string is provided as env in Kubernetes by secrets manager
29+
# it should not be provided for other environments (local etc)
30+
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
31+
COPY --chmod=755 ./applicationinsights.json /usr/src/jore4-auth/applicationinsights.json
32+
2533
# copy over compiled jar
2634
COPY --from=builder /build/target/*.jar /usr/src/jore4-auth/auth-backend.jar
2735

2836
# read docker secrets into environment variables and run application
29-
CMD ["/bin/bash", "-c", "source /app/scripts/read-secrets.sh && java -jar /usr/src/jore4-auth/auth-backend.jar"]
37+
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"]
3038

3139
HEALTHCHECK --interval=1m --timeout=5s \
3240
CMD curl --fail http://localhost:8080/actuator/health

applicationinsights.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"role": {
3+
"name": "jore4-auth"
4+
}
5+
}

0 commit comments

Comments
 (0)