Dockerfile and startsup.sh modification to refer to -javaagent jar file correctly

8/15/2017

My dockerfile looks like this:

    FROM xx.com:5100/namespace/anapsix/alpine-java:8_jdk
    VOLUME /tmp
    ADD application-0.0.1-SNAPSHOT.jar app.jar
    ADD application2-0.0.1-SNAPSHOT-jar-with-dependencies.jar app2.jar
    VOLUME /etc
    ADD /etc/ /etc/
    ADD startService.sh /startService.sh
    RUN chmod 700 /startService.sh
    ENTRYPOINT ./startService.sh 

My startup.sh file is this:

#!/bin/sh

touch /app.jar
touch /app2.jar
java -Djava.security.egd=file:/dev/./urandom -Xms1024m -Xmx1024m -jar -javaagent:/app2.jar -DILIB_APPNAME=K8S_ANNOTATION_HELLO_SERVICE -jar /app.jar

Issue: When I insert this app2.jar in both the Dockerfile and startup.sh files and then deploy my microservice to kubernetes, I cannot call the nodePort service in kubernetes.

However, I am able to call the service if I get rid of all lines with app2.jar.

But for my usecase, I need this app2.jar as well as the app.jar.

Oh also, the jar file: application2-0.0.1-SNAPSHOT-jar-with-dependencies.jar is located in the same folder as the Dockerfile and startup.sh.

How should I tweak my files so that it doesn't break in kubernetes?

Thank you

-- hifzizzle
dockerfile
jar
java
kubernetes

0 Answers