Skip to content

Commit

Permalink
fix(docker): exclude .dockerignore from context hash
Browse files Browse the repository at this point in the history
Since `.dockerignore` is a means to control what is in the build
context, the contents of the file itself should not be included in the
context hash. See #117 for more details.

Closes #117
  • Loading branch information
ethanwu10 committed Feb 27, 2021
1 parent 2107b0a commit db0fb48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rcds/challenge/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def get_context_files(root: Path) -> Iterator[Path]:
for line in fd
),
)
files = filter(lambda p: not spec.match_file(p.relative_to(root)), files)
files = filter(
lambda p: not spec.match_file(p.relative_to(root)) and p != dockerignore,
files,
)
return filter(lambda p: p.is_file(), files)


Expand Down
2 changes: 1 addition & 1 deletion tests/challenge/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_with_dockerignore(self, datadir: Path) -> None:
df_root = datadir / "contexts" / "dockerignore"
assert df_root.is_dir()
got = {str(p.relative_to(df_root)) for p in docker.get_context_files(df_root)}
assert got == {"Dockerfile", ".dockerignore", ".file", "file"}
assert got == {"Dockerfile", ".file", "file"}

def test_complex_dockerignore(self, datadir: Path) -> None:
df_root = datadir / "contexts" / "complex_dockerignore"
Expand Down

0 comments on commit db0fb48

Please sign in to comment.