在 .dockerignore 中排除文件夹

3

我正在尝试防止将Drupal组合器项目中的文件和文件夹列表包含在docker镜像中,但意外的副作用是它也排除了一些未在.dockerignore中明确定义的文件夹。这是我正在使用的文件:

# root files
.gitignore
.gitmodules
.travis.yml
.gitlab-ci.yml
docker-compose.yml
LICENSE
phpunit.xml.dist
README.md

# folders
.c9
.git
backups/
vendor/
web/core/
web/modules/contrib/
web/profiles/
web/themes/contrib/

# web files
web/.csslintrc
web/.editorconfig
web/.eslintrc
web/.eslintignore
web/.gitattributes
web/.htaccess

# web sites files
web/sites/development.services.yml
web/sites/example.settings.local.php
web/sites/example.sites.php

# web sites default files
web/sites/default/files/
web/sites/default/default.services.yml
web/sites/default/settings.local.php

<all combinations of lines below, one at a time>

我已经在底部定义了要包括的文件夹,我尝试了下面所有我能想到的组合。到目前为止都没有成功,也没有更多的尝试。

# don't ignore comes last
!web/themes/custom
!web/libraries

# don't ignore comes last
!web/themes/custom/
!web/libraries/

# don't ignore comes last
!web/themes/custom/*
!web/libraries/*

# don't ignore comes last
*!web/themes/custom/*
*!web/libraries/*

我也试图取消注释每个文件夹,但是web/themes/customweb/libraries 文件夹仍未显示在我的Docker镜像中。我还有一个包含这些文件夹的.gitignore文件。也许这是导致这种奇怪行为的原因?任何帮助将不胜感激。

根据您提供的细节,我无法重现此问题。请按照此答案中的步骤进行操作,并将您的结果与构建输出以及在构建目录中运行的find .一起发布。 - BMitch
问题已解决,请查看下面的答案。 - Hyperfocus1337
1个回答

0

我正在使用Gitlab CI构建镜像,但我忘记了我的git仓库中没有我想要复制的文件夹。只有我的本地开发环境有这些文件夹。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接