I have the following docker file that runs a spring boot application
:
# For Java 11, try this
FROM adoptopenjdk/openjdk11:alpine-jre
#
ARG JAR_FILE=/build/libs/pokerstats-0.0.1-SNAPSHOT.jar
#
WORKDIR /opt/app
#
COPY ${JAR_FILE} app.jar
#
ENTRYPOINT ["java","-jar","app.jar"]
The issue is that currently I have to run gradle clean build
on my host machine first to create the jar file on my local machine at path:
/build/libs/pokerstats-0.0.1-SNAPSHOT.jar
How can I put this gradle clean build
into my docker file so that the build step is done inside the container?
edit:
I want the steps for a user to be:
- Clone my project from
github
- run
docker build -t pokerstats .
- which will do the gradle build - run docker container run -d -p 8080:8080 pokerstats
The user will clone my project from github - I then want them to be able to run the docker container without having to build the project with gradle first - I.e. I want the docker file to do the build and copy the jar into the container.