Open mcandre opened 1 month ago
I'll transfer this ticket to the buildx
repository, because it is related to docker build
, which is now handled (by default) by buildx
.
I'm not sure if changing the defaults would be possible though. While it's common for some scenarios to exclude certain files (e.g. the Dockerfile itself, or the .git
directory), there are also many scenarios where these files are intentionally part of the build context. The .git
directory in many scenarios may be used as part of builds to determined versions used; often this would be consumed through a RUN --mount ...
, but currently mounting from a build-context also is restricted by .dockerignore
.
There's some tickets related to .dockerignore
; one epic that collects various related topics;
Which also has a linked ticket about supporting a global .dockerignore
(which could allow defining your own "defaults");
However, defining a global ignore also comes with consequences; it can complicate debugging (why is a file missing from my build?), so may need additional features to expose what's ignored (something similar to git check ignore
)
Description
By default, docker builds should exclude common patterns from
ADD
/COPY
directives:*Dockerfile*
, including the standardDockerfile
path, as well as any user customDockerfile.<extension>
,Dockerfile-<extension>
,<environment>.Dockerfile
,<environment>-Dockerfile
, etc. auxiliary configurationsgit ls-files
, including the per-directory .gitignore system and gitignore --global per-user system. The latter is a scalable way to maintain OS and editor specific exclusion patterns, without having to track thousands of these depending on random contributor machine setups. The Go library https://github.com/go-git/go-git can help manage that.