gpt4 book ai didi

Dockerignore : Ignore everything except a file and the Dockerfile

转载 作者:IT老高 更新时间:2023-10-28 12:34:59 28 4
gpt4 key购买 nike

所以主要目的是将胖 jar 应用程序 docker 化并放入 Elasticbeanstalk。问题在于上下文。如果我实际上只需要一个 jar 文件,那么在 docker 中添加这么多上下文有点愚蠢。

我一直在玩弄 .dockerignore 文件,但我迷路了。我尝试使用 gitignore 否定,但它不起作用。

*
!Dockerfile
*/
!target/
target/*
!target/*.jar

正则表达式也有这种情况,但似乎不支持复杂的正则表达式。

^((?!Dockerfile).)*$

我也试过在stackoverflow中搜索,找到的都是这两个:

这个问题可能与第二个问题类似,但我认为它略有不同,因为在这里,我只想在上下文中包含一个文件。

任何帮助将不胜感激。

最佳答案

如果您需要忽略除某些目录或文件之外的所有内容,并且还需要忽略那些允许的目录中的一些不必要的文件,您可以使用以下 .dockerignore 文件:

# Ignore everything
*

# Allow files and directories
!/file.txt
!/src

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/*~
**/*.log
**/.DS_Store
**/Thumbs.db

关于Dockerignore : Ignore everything except a file and the Dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28097064/

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