Skip to content

Support dockerfile specific ignore#67

Open
JaewonHur wants to merge 1 commit intoapple:mainfrom
JaewonHur:support-docker-specific-ignore
Open

Support dockerfile specific ignore#67
JaewonHur wants to merge 1 commit intoapple:mainfrom
JaewonHur:support-docker-specific-ignore

Conversation

@JaewonHur
Copy link
Contributor

This PR adds support for Dockerfile.dockerignore (apple/container#1169).
It comes with performance overhead as it requires one more buildkit communication (i.e., ReadEntrypoint).

Test results is as below:

╰─❯ TOOL=container ./test-ignore.sh
==========================================
Running .dockerignore tests with: container
==========================================

[TEST] Test 1: Basic .dockerignore
  $ ( cd test1-basic ; container build -t test-ignore:latest . )
[PASS] included.txt was copied (expected)
[PASS] ignored.txt was NOT copied (expected)

[TEST] Test 2: Dockerfile-specific ignore (Dockerfile.dockerignore)
  $ ( cd test2-specific ; container build -t test-ignore:latest . )
[PASS] specific.txt was NOT copied (correctly ignored by Dockerfile.dockerignore)
[PASS] general.txt was copied (only ignored by .dockerignore, not Dockerfile.dockerignore)

[TEST] Test 3: Containerfile with .containerignore
  $ ( cd test3-containerfile ; container build -f Containerfile -t test-ignore:latest . )
[PASS] included.txt was copied (expected)
[FAIL] ignored.txt was copied (unexpected)

[TEST] Test 4: Containerfile-specific ignore (Containerfile.containerignore)
  $ ( cd test4-containerfile-specific ; container build -f Containerfile -t test-ignore:latest . )
[FAIL] specific.txt was copied (should be ignored by Containerfile.containerignore)
[PASS] general.txt was copied (only ignored by .containerignore, not Containerfile.containerignore)

[TEST] Test 5: Build succeeds when Dockerfile is ignored
  $ ( cd test5-ignored-dockerfile ; container build -f Dockerfile -t test-ignore:latest . )
[PASS] Build succeeded even with Dockerfile in .dockerignore
[PASS] test.txt was copied (expected)

[TEST] Test 6: Build from subdirectory context
  $ ( cd test6-subdir ; container build -f subcontext/Dockerfile -t test-ignore:latest subcontext )
[PASS] included.txt was copied (expected)
[PASS] ignored.txt was NOT copied (expected)

[TEST] Test 7: No ignore file (all files should be copied)
  $ ( cd test7-no-ignore ; container build -t test-ignore:latest . )
[PASS] file1.txt was copied (expected)
[PASS] file2.txt was copied (expected)

[TEST] Test 8: Build with --platform and Dockerfile in subdirectory
  $ ( cd test8-platform-subdir-dockerfile ; container build --platform linux/amd64 -t test-ignore:latest -f nested/project/Dockerfile . )
[FAIL] included.txt was NOT copied (should be included)
[PASS] secret.txt was NOT copied (correctly ignored by Dockerfile.dockerignore)
[FAIL] nested/project/config.txt was NOT copied (unexpected)

[TEST] Test 9: Custom-named Dockerfile (app1.Dockerfile)
  $ ( cd test9-custom-dockerfile-name ; container build -f app1.Dockerfile -t test-ignore:latest . )
[FAIL] app1-specific.txt was copied (should be ignored by app1.Dockerfile.dockerignore)
[FAIL] generic.txt was NOT copied (should be included)
[PASS] included.txt was copied (expected)

[TEST] Test 10: Custom-named Dockerfile in subdirectory
  $ ( cd test10-custom-name-subdir ; container build -f nested/project/app2.Dockerfile -t test-ignore:latest . )
[FAIL] from-app2-ignore.txt was copied (should be ignored by app2.Dockerfile.dockerignore)
[FAIL] from-root-ignore.txt was NOT copied (should be included)
[PASS] always-included.txt was copied (expected)
[PASS] nested/project/config.yaml was copied (expected)

==========================================
Test Summary
==========================================
Passed: 16
Failed: 8
==========================================

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.

1 participant