Skip to content

add docker copy_config_files profile field - #20332

Open
davidsanfal wants to merge 7 commits into
conan-io:develop2from
davidsanfal:feature/runner_extra_files
Open

davidsanfal wants to merge 7 commits into
conan-io:develop2from
davidsanfal:feature/runner_extra_files

Conversation

@davidsanfal

@davidsanfal davidsanfal commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Changelog: Feature: Add copy_config_files setting to the [runner] profile section (Docker runner), allowing to copy extra host config files/folders into the container, opt-in and disabled by default.
Docs: https://github.com/conan-io/docs/pull/XXXX
Closes: #20281

Adds a new opt-in copy_config_files key to the [runner] profile section, accepting a comma-separated list of fnmatch patterns relative to the Conan home folder, e.g.:

[runner]
type=docker
copy_config_files=extensions/*

It's opt-in and empty by default, so existing profiles/behavior are unaffected.

Comment thread test/functional/command/runner_test.py Outdated
@davidsanfal davidsanfal added this to the 2.33.0 milestone Sep 17, 2026
@davidsanfal
davidsanfal marked this pull request as ready for review September 17, 2026 18:16
Comment thread conan/internal/runner/docker.py Outdated
Comment on lines +27 to +29
LOCALDB, # sqlite db with remote login tokens (plain text)
"sources/*", # default backup-sources cache (core.sources:download_cache)
".local_recipes_index/*", # local clones of local-recipes-index remotes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "package storage" folder (p) seems to be missing here.
Also, the version.txt that declares the version installed in the machine should probably never be copied either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the package storage folder (p by default, but relocatable via core.cache:storage_path) is excluded where it is used.

storage_path = Path(self.conan_api._api_helpers.cache.store)
if storage_path.is_relative_to(self.conan_api.home_folder):
    excludes.append(f"{storage_path.relative_to(self.conan_api.home_folder).as_posix()}/*")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is my question, why not just ignoring the default p subfolder?, instead of such automatic exclusion computation including a check to see if it is relative or not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was changed in the latest commit, and I also added a rule to always exclude the download_cache too

# (``core.cache:storage_path``) and the sources backup cache (``core.sources:download_cache``)
# are excluded too, dynamically, where they are used below, since both are relocatable confs.
_DEFAULT_EXCLUDED_COPY_PATTERNS = [
LOCALDB, # sqlite db with remote login tokens (plain text)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same reason shouldn't we also skip credentials.json and source_credentials.json and maybe adding those explicitly to the copy would override this skip?

client.run("new cmake_lib -d name=pkg -d version=0.2")
client.run("create . -pr:h host_copy -pr:b build")

assert "my custom profile plugin running" in client.out

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not testing the feature is working, this will also run for the host, before the docker even runs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about letting explicit patterns override the default excludes, but that falls apart for wildcard excludes like .local_recipes_index/* (a request for .local_recipes_index/foo just wouldn't match it), and getting the general case right would mean fiddly glob intersection logic that's easy to get wrong. So instead I made the exclude list itself a new copy_config_files_excludes setting, defaulting to what we have now. If someone needs to bring back a file, they just set it explicitly in their profile, no hidden override rules to reason about.

@czoido czoido Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about adding another configuration like copy_config_files_excludes What about two groups instead of copy_config_files_excludes?

  • Always excluded, not overridable: version.txt and .local_recipes_index/*.
  • Sensitive, excluded unless listed by exact name in copy_config_files: .conan.db, credentials.json, source_credentials.json.

All wildcard excludes are in the fixed group, so no glob intersection is needed, and we keep a single setting. With the current approach, copy_config_files_excludes=.conan.db,source_credentials.json (to copy credentials.json) replaces the whole default list, so version.txt and .local_recipes_index/ get copied too unless the user remembers to list them again.

@davidsanfal davidsanfal changed the title add docker extra_file profile field add docker copy_config_files profile field Sep 24, 2026
Comment thread test/functional/command/runner_test.py Outdated
client.run("create . -pr:h host_copy -pr:b build")

assert "my custom profile plugin running" in client.out
assert client.out.count("my custom profile plugin running") == 4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this checks tend to be fragile, wouldn't it be easier to check:

assert "conan-runner-docker | my custom profile plugin running" in client.out

Comment thread conan/internal/runner/docker.py
Comment thread conan/internal/runner/docker.py Outdated
from conan.internal.cache.home_paths import HomePaths
from conan.tools.files import copy

# Default value of the ``copy_config_files_excludes`` [runner] setting, overridable in the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this copy_config_files_excludes? I think this makes the code more complex. In my mind, the use case would be:

copy_config_files=extensions/*
copy_config_files=extensions/*,otherfolder/* 

Or even

copy_config_files=*   # copy all the non-excluded files

If the user wants to copy an excluded file deliberately, then they should put it in the settings explicitly:

copy_config_files=extensions/*,credentials.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested doing something like this: #20332 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I did not see your comment above 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Extensions not copied for Docker runner

4 participants