-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (33 loc) · 1.94 KB
/
Dockerfile
File metadata and controls
46 lines (33 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM maven:3-eclipse-temurin-17 AS builder
# set up workdir
WORKDIR /build
# download dependencies
COPY ./pom.xml /build
RUN mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies
# copy sources
COPY ./src /build/src
# package using "prod" profile
COPY ./profiles/prod /build/profiles/prod
RUN mvn -Pprod -DskipTests=true clean package spring-boot:repackage
FROM eclipse-temurin:25.0.2_10-jre
# Application Insights version
ARG APPINSIGHTS_VERSION=3.7.7
# expose server port
EXPOSE 8080
# download script for reading Docker secrets
ADD --chmod=555 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /tmp/read-secrets.sh
# Downaload a Java applet to perform HEALTHCHECK with
ADD --chmod=444 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/HealthCheck.jar /app/scripts/HealthCheck.jar
# Connection string is provided as env in Kubernetes by secrets manager
# it should not be provided for other environments (local etc)
RUN mkdir -p /usr/src/jore4-map-matching
ADD --chmod=444 https://github.com/microsoft/ApplicationInsights-Java/releases/download/${APPINSIGHTS_VERSION}/applicationinsights-agent-${APPINSIGHTS_VERSION}.jar /usr/src/jore4-map-matching/applicationinsights-agent.jar
COPY --chmod=444 ./applicationinsights.json /usr/src/jore4-map-matching/applicationinsights.json
# add helper script for constructing JDBC URL
COPY --chmod=555 ./scripts/build-jdbc-urls.sh /tmp/build-jdbc-urls.sh
# copy compiled jar from builder stage
COPY --from=builder /build/target/*.jar /usr/src/jore4-map-matching/jore4-map-matching.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 -javaagent:/usr/src/jore4-map-matching/applicationinsights-agent.jar -jar /usr/src/jore4-map-matching/jore4-map-matching.jar"]
HEALTHCHECK --interval=1m --timeout=5s \
CMD ["java", "-jar", "/app/scripts/HealthCheck.jar"]