This is my Dockerfile:
FROM openjdk:17
COPY ./out/production/Company /tmp
WORKDIR /tmp
ENTRYPOINT ["java","Main"]
When I run the Dockerfile I get errors because my project is using a Maven dependency: org.json
I need help editing my Dockerfile to include this Maven dependency
CodePudding user response:
The easiest way then for you is to use the jib
plugin.
Add the plugin to your project, then create an entrypoint.sh
that tells Docker how to start the app.
Then execute the plugin to build the Docker image. It will figure out all the dependencies and bundle it into the Docker image.
Link: https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin
CodePudding user response:
I ended up just making my maven project into a jar file and that fixed the dependency problem.
My Dockerfile looks like this:
FROM openjdk:17
ADD out/artifacts/Company_jar/Company.jar Company.jar
ENTRYPOINT ["java", "-jar","Company.jar"]
There are multiple solutions so I gave the first response as the answer because I would have used the plugin if not for the jar solution.