Skip to content

Commit 4da414c

Browse files
committed
Fix Docker file
* Removed `applicationinsights.json` from `.gitignore` as that prevents docker from finding that file, as docker reads and respects `.gitignore`. * Fixed file permissions: - Only script files should be executable. - No file should be writable. - Files should be readable. * Fixed `HEALTHCHECK`. The Ubuntu base image used by our `eclipse-temurin` Docker base image, does not provide `curl` or any other alterntives. Instead of installing `curl` and polluting the image with APT cache stuff, a simple custom Java based applet is used to check the status. This allows us to in the future to also switch to completely distroless base images.
1 parent df5f46d commit 4da414c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
!/profiles
77
!/pom.xml
88
!/read-secrets.sh
9+
!/applicationinsights.json

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ ARG APPINSIGHTS_VERSION=3.7.7
2222
# expose server port
2323
EXPOSE 8080
2424

25-
# download script for reading docker secrets
26-
ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /app/scripts/read-secrets.sh
25+
# Download script for reading docker secrets
26+
ADD --chmod=555 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /app/scripts/read-secrets.sh
27+
28+
# Downaload a Java applet to perform HEALTHCHECK with
29+
ADD --chmod=444 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/HealhtCheck.jar /app/scripts/HealhtCheck.jar
2730

2831
# Connection string is provided as env in Kubernetes by secrets manager
2932
# 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
33+
ADD --chmod=444 https://github.com/microsoft/ApplicationInsights-Java/releases/download/${APPINSIGHTS_VERSION}/applicationinsights-agent-${APPINSIGHTS_VERSION}.jar /usr/src/jore4-auth/applicationinsights-agent.jar
34+
COPY --chmod=444 ./applicationinsights.json /usr/src/jore4-auth/applicationinsights.json
3235

3336
# copy over compiled jar
3437
COPY --from=builder /build/target/*.jar /usr/src/jore4-auth/auth-backend.jar
@@ -37,4 +40,4 @@ COPY --from=builder /build/target/*.jar /usr/src/jore4-auth/auth-backend.jar
3740
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"]
3841

3942
HEALTHCHECK --interval=1m --timeout=5s \
40-
CMD curl --fail http://localhost:8080/actuator/health
43+
CMD ["java", "-jar", "/app/scripts/HealhtCheck.jar"]

0 commit comments

Comments
 (0)