Skip to content

Commit bfd361b

Browse files
author
Joonas Hiltunen
committed
Enable Application Insights
1 parent 7b2631a commit bfd361b

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ RUN mvn -Pprod -DskipTests=true clean package spring-boot:repackage
1616

1717
FROM eclipse-temurin:25.0.1_8-jre
1818

19+
# Application Insights version
20+
ARG APPINSIGHTS_VERSION=3.7.7
21+
1922
RUN apt-get update && apt-get install -y curl
2023

2124
# expose server port
@@ -24,14 +27,19 @@ EXPOSE 8080
2427
# download script for reading Docker secrets
2528
ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /tmp/read-secrets.sh
2629

30+
# Connection string is provided as env in Kubernetes by secrets manager
31+
# it should not be provided for other environments (local etc)
32+
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
33+
COPY --chmod=755 ./applicationinsights.json /usr/src/jore4-timetables/applicationinsights.json
34+
2735
# copy over helper scripts
2836
COPY --chmod=755 ./script/build-jdbc-urls.sh /tmp/
2937

3038
# copy compiled jar from builder stage
3139
COPY --from=builder /build/target/*.jar /usr/src/jore4-timetables/jore4-timetables.jar
3240

3341
# read Docker secrets into environment variables and run application
34-
CMD ["/bin/bash", "-c", "source /tmp/read-secrets.sh && source /tmp/build-jdbc-urls.sh && java -jar /usr/src/jore4-timetables/jore4-timetables.jar"]
42+
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"]
3543

3644
HEALTHCHECK --interval=1m --timeout=5s \
3745
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-timetables"
4+
}
5+
}

0 commit comments

Comments
 (0)