skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search