Reputation: 707
I am working with Spring boot. The following Dockerfile and run.sh is working fine and the docker image is built using the docker-plugin in build.gradle.
Now I want to make a docker image of an application that uses some functions of Java11. So, If I made a docker image from the following Dockerfile. How could I do so ? So, that Java11 functions could be accessible with the docker image.
build.gradle
task buildDocker(type: Docker, dependsOn: build) {
push = false
applicationName = jar.baseName
dockerfile = file('src/main/docker/Dockerfile')
doFirst {
copy {
from jar
into stageDir
}
copy {
from "${project.buildDir}/resources/main/run.sh"
into stageDir
}
}
Dockerfile
FROM openjdk:8u121-jdk-alpine
# Keep consistent with build.gradle
ENV APP_JAR_NAME pineCharts
# Install curl
RUN apk --update add curl bash && \
rm -rf /var/cache/apk/*
RUN mkdir /app
ADD ${APP_JAR_NAME}.jar /app/
ADD run.sh /app/
RUN chmod +x /app/run.sh
WORKDIR /app
EXPOSE 8082
ENTRYPOINT ["/bin/bash","-c"]
CMD ["/app/run.sh"]
run.sh
#!/usr/bin/env bash
java -Djava.security.egd=file:/dev/urandom -Dspring.profiles.active=${SPRING_ACTIVE_PROFILE} -Dgit.config.active.branch=${GIT_BRANCH_LABEL} -Duser.timezone=Asia/Kolkata -XX:+PrintFlagsFinal $JAVA_OPTIONS -jar ${APP_JAR_NAME}.jar
Upvotes: 0
Views: 3012
Reputation: 13933
Here is an example
FROM adoptopenjdk/openjdk11:latest
RUN mkdir -p /software/app
ADD target/app.jar /software/app/app.jar
ENV port=8888
CMD java -jar /software/app/app.jar -Dspring.profiles.active=${SPRING_ACTIVE_PROFILE}
Upvotes: 1