Skip to content

Commit db0fb48

Browse files
committed
fix(docker): exclude .dockerignore from context hash
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
1 parent 2107b0a commit db0fb48

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

rcds/challenge/docker.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def get_context_files(root: Path) -> Iterator[Path]:
5858
for line in fd
5959
),
6060
)
61-
files = filter(lambda p: not spec.match_file(p.relative_to(root)), files)
61+
files = filter(
62+
lambda p: not spec.match_file(p.relative_to(root)) and p != dockerignore,
63+
files,
64+
)
6265
return filter(lambda p: p.is_file(), files)
6366

6467

tests/challenge/test_docker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_with_dockerignore(self, datadir: Path) -> None:
2626
df_root = datadir / "contexts" / "dockerignore"
2727
assert df_root.is_dir()
2828
got = {str(p.relative_to(df_root)) for p in docker.get_context_files(df_root)}
29-
assert got == {"Dockerfile", ".dockerignore", ".file", "file"}
29+
assert got == {"Dockerfile", ".file", "file"}
3030

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

0 commit comments

Comments
 (0)