用带有依赖关系的 JAR 文件创建一个 Docker 容器

huangapple 未分类评论48阅读模式
英文:

Creating a docker container from a jar file with depedencies

问题

我已创建了一个Java应用程序,用于将CSV数据解析成JSON文件。我已将其打包成相应的JAR文件,而且Eclipse还创建了一个包含所有依赖JAR文件的lib文件夹。
[这是目录][1],正如您所见,它还包含我正在解析的data.csv文件。

现在我正在尝试创建一个Docker镜像,以运行我的JAR文件,唯一的问题是我不确定如何构建我的Docker文件以包含JAR文件和所有依赖项(包括CSV文件)。以下是我当前的Docker文件:

FROM openjdk:12-alpine
COPY RunnableApplication/CsvParser_lib /run/dependency-jars
COPY ./RunnableApplication/CsvParser.jar /usr/app/
WORKDIR /usr/app
ENTRYPOINT ["java", "-jar", "CsvParser.jar"]


是否有办法将csvParser_lib文件夹以及data.csv文件添加到容器中,以便我可以运行具有其依赖项的JAR文件?非常感谢您的任何帮助!

  [1]: https://i.stack.imgur.com/uxJc1.png
英文:

I have created a java application that parses CSV data into a json file. I have packaged it out into its respective jar file and eclipse has also created a lib folder containing all my dependant jar files.
Here is the directory as you can see it also contains the data.csv file i am parsing.

Now i am trying to create a docker image that will run my jar file, the only problem is i am unsure of how to sturcture my docker file to contain the jar file, and the dependencies (including the csv file) also. Here is the current docker file i have:

FROM openjdk:12-alpine
COPY RunnableApplication/CsvParser_lib /run/dependency-jars
COPY ./RunnableApplication/CsvParser.jar /usr/app/
WORKDIR /usr/app
ENTRYPOINT ["java", "-jar", "CsvParser.jar"]

Is there a way to add the csvParser_lib folder aswell as the data.csv file to the container so i can run the jar file with its dependencies? Any help would be greatly appreciated!

huangapple
  • 本文由 发表于 2020年7月26日 23:23:47
  • 转载请务必保留本文链接:https://java.coder-hub.com/63102099.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定