gpt4 book ai didi

maven - spotify dockerfile-maven Dockerfile

转载 作者:行者123 更新时间:2023-12-02 19:30:09 30 4
gpt4 key购买 nike

我是一个 docker maven 插件新手。

如果我理解得很好,根据Spotify's Dockerfile Maven documentation ,应该将 Dockerfile 放在我的项目的根目录中(我正在运行一个 spring boot 项目)。

引用 docker 的 Best practices for writing Dockerfiles :

Regardless of where the Dockerfile actually lives, all of the recursive contents of files and directories in the current directory are sent to the Docker daemon as the build context. Inadvertently including files that are not necessary for building the image results in a larger build context and larger image size.



这是否意味着当 Spotify Dockerfile Maven 插件运行配置时,我正在公开发送给 docker 守护进程的源文件夹?

最佳答案

回答

默认情况下,是的,构建上下文将包括您的源(和目标)目录。但是,您可以添加 .dockerignore文件告诉它不要这样做。

如果您不确定这是什么,请查看 this tutorial.

观点

IMO:我可以想象从 maven 运行 docker 的场景是正确的做法。但是,我的想象力非常好,不会有那么多商店采用 docker 但不改变他们遗留的 maven 构建管道。

但在大多数情况下,您不想这样做。

相反,您应该使用一个 docker 容器来构建 java Artifact 并运行单元测试。然后,这可以将 Artifact 推送到 nexus(或您正在使用的任何 repo)。如果这是一个 webapp 或其他 http 服务,那么您可以使用第二个容器来托管它并将其部署到环境中以对其进行集成测试。

关于maven - spotify dockerfile-maven Dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52165814/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com