Skip to content

Commit fdf9eeb

Browse files
author
Joonas Hiltunen
committed
Enable Application Insights
1 parent 12f24b9 commit fdf9eeb

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
@@ -15,6 +15,9 @@ RUN mvn -Pprod -DskipTests=true clean package spring-boot:repackage
1515

1616
FROM eclipse-temurin:25.0.1_8-jre
1717

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

@@ -26,14 +29,19 @@ RUN apt-get update \
2629
# download script for reading Docker secrets
2730
ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /tmp/read-secrets.sh
2831

32+
# Connection string is provided as env in Kubernetes by secrets manager
33+
# it should not be provided for other environments (local etc)
34+
ADD --chmod=755 https://github.com/microsoft/ApplicationInsights-Java/releases/download/${APPINSIGHTS_VERSION}/applicationinsights-agent-${APPINSIGHTS_VERSION}.jar /usr/src/jore4-map-matching/applicationinsights-agent.jar
35+
COPY --chmod=755 ./applicationinsights.json /usr/src/jore4-map-matching/applicationinsights.json
36+
2937
# add helper script for constructing JDBC URL
3038
COPY --chmod=755 ./scripts/build-jdbc-urls.sh /tmp/build-jdbc-urls.sh
3139

3240
# copy compiled jar from builder stage
3341
COPY --from=builder /build/target/*.jar /usr/src/jore4-map-matching/jore4-map-matching.jar
3442

3543
# read Docker secrets into environment variables and run application
36-
CMD ["/bin/bash", "-c", "source /tmp/read-secrets.sh && source /tmp/build-jdbc-urls.sh && java -jar /usr/src/jore4-map-matching/jore4-map-matching.jar"]
44+
CMD ["/bin/bash", "-c", "source /tmp/read-secrets.sh && source /tmp/build-jdbc-urls.sh && java -javaagent:/usr/src/jore4-map-matching/applicationinsights-agent.jar -jar /usr/src/jore4-map-matching/jore4-map-matching.jar"]
3745

3846
HEALTHCHECK --interval=1m --timeout=5s \
3947
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-map-matching"
4+
}
5+
}

0 commit comments

Comments
 (0)