Skip to content

feat(remote): support .dockerignore when copying files to remote host - #1801

Open
cathaysia wants to merge 4 commits into
cross-rs:mainfrom
cathaysia:feat/remote-dockerignore
Open

cathaysia wants to merge 4 commits into
cross-rs:mainfrom
cathaysia:feat/remote-dockerignore

Conversation

@cathaysia

Copy link
Copy Markdown
Contributor

Support .dockerignore files when copying project and mounted volumes to remote container data volumes.

Changes

  • Add docker_ignore module for .dockerignore parsing and pattern matching based on the glob crate:
    • Supports comments (#), blank lines, and UTF-8 BOM.
    • Supports negation / exception rules (!) in sequential order.
    • Supports directory-only patterns (/ suffix).
    • Matches root-relative and recursive (**) patterns using glob::MatchOptions { require_literal_separator: true, .. } following Docker / Moby patternmatcher specifications.
    • Respects parent directory exclusion hierarchy (excluding a parent directory prunes children).
  • Integrate .dockerignore filtering into directory copying (copy_dir_with_rel and copy_files_filtered) in remote.rs, skipping ignored files and directories during traversal.
  • Integrate .dockerignore filtering into Fingerprint scanning so persistent volume incremental sync respects ignore rules.
  • Add comprehensive unit tests covering parsing, pattern matching, exception rules, directory copying, and fingerprint scanning.

close #1800

@cathaysia
cathaysia requested a review from a team as a code owner September 7, 2026 02:19
@cathaysia
cathaysia force-pushed the feat/remote-dockerignore branch from 3a54724 to 08e215c Compare September 7, 2026 02:20
Add DockerIgnore support using the glob crate to filter files and directories when copying project and mounted volumes to remote container data volumes. Also integrate with Fingerprint to ensure persistent volume incremental updates respect .dockerignore.
@cathaysia
cathaysia force-pushed the feat/remote-dockerignore branch from 08e215c to f27c491 Compare September 7, 2026 02:52
@cathaysia

Copy link
Copy Markdown
Contributor Author

Hi, could someone please review this?

@Emilgardis Emilgardis left a comment

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.

I think this is fine, some minor nits. One thing this makes me consider is if we should just switch to use ignore which is based on walkdir to traverse the mount

Comment thread src/docker/docker_ignore.rs Outdated
Comment thread src/docker/docker_ignore.rs Outdated
Replace escaped \n string literals with multi-line raw strings so
.dockerignore test content is readable at a glance.
Podman prefers `.containerignore` with a fallback to `.dockerignore`,
while Docker only reads `.dockerignore`. Warn when the chosen file
does not match the running engine.
@cathaysia
cathaysia force-pushed the feat/remote-dockerignore branch from a27d2eb to 4eaee6b Compare September 10, 2026 03:49
Replace recursive copy_dir_with_rel and Fingerprint::_read_dir with a
VecDeque queue so deeply nested contexts cannot blow the stack, while
preserving skip/dockerignore pruning and depth-aware callbacks.
@cathaysia

Copy link
Copy Markdown
Contributor Author

I think this is fine, some minor nits. One thing this makes me consider is if we should just switch to use ignore which is based on walkdir to traverse the mount

Considering that most of the traversal work involves pruning, using walkedir may not be as beneficial as we thought. I changed the recursion to iteration to avoid potential stack overflow issues.

@cathaysia

Copy link
Copy Markdown
Contributor Author

Is there anything else here that needs to be modified?

@Emilgardis

Copy link
Copy Markdown
Member

No, just need to have a look at the changes once more and then can merge :)

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.

Support .dockerignore

2 participants