Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,11 +0,0 @@ |
| 1 |
-FROM busybox |
|
| 2 |
-RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
|
| 3 |
-RUN echo 'dockerio:x:1001:' >> /etc/group |
|
| 4 |
-RUN touch /exists |
|
| 5 |
-RUN chown dockerio.dockerio exists |
|
| 6 |
-COPY test_dir /test_dir |
|
| 7 |
-RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 8 |
-RUN [ $(ls -l / | grep test_dir | awk '{print $1}') = 'drwxr-xr-x' ]
|
|
| 9 |
-RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 10 |
-RUN [ $(ls -l /test_dir/test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
| 11 |
-RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
|
| ... | ... |
@@ -784,32 +784,28 @@ RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`,
|
| 784 | 784 |
} |
| 785 | 785 |
|
| 786 | 786 |
func TestBuildCopyWholeDirToRoot(t *testing.T) {
|
| 787 |
- testDirName := "WholeDirToRoot" |
|
| 788 |
- sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName) |
|
| 789 |
- buildDirectory, err := ioutil.TempDir("", "test-build-add")
|
|
| 790 |
- defer os.RemoveAll(buildDirectory) |
|
| 791 |
- |
|
| 792 |
- err = copyWithCP(sourceDirectory, buildDirectory) |
|
| 787 |
+ name := "testcopywholedirtoroot" |
|
| 788 |
+ defer deleteImages(name) |
|
| 789 |
+ ctx, err := fakeContext(`FROM busybox |
|
| 790 |
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
|
| 791 |
+RUN echo 'dockerio:x:1001:' >> /etc/group |
|
| 792 |
+RUN touch /exists |
|
| 793 |
+RUN chown dockerio.dockerio exists |
|
| 794 |
+COPY test_dir /test_dir |
|
| 795 |
+RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 796 |
+RUN [ $(ls -l / | grep test_dir | awk '{print $1}') = 'drwxr-xr-x' ]
|
|
| 797 |
+RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 798 |
+RUN [ $(ls -l /test_dir/test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
| 799 |
+RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
|
| 800 |
+ map[string]string{
|
|
| 801 |
+ "test_dir/test_file": "test1", |
|
| 802 |
+ }) |
|
| 793 | 803 |
if err != nil {
|
| 794 |
- t.Fatalf("failed to copy files to temporary directory: %s", err)
|
|
| 795 |
- } |
|
| 796 |
- |
|
| 797 |
- buildDirectory = filepath.Join(buildDirectory, testDirName) |
|
| 798 |
- testDir := filepath.Join(buildDirectory, "test_dir") |
|
| 799 |
- if err := os.MkdirAll(testDir, 0755); err != nil {
|
|
| 800 | 804 |
t.Fatal(err) |
| 801 | 805 |
} |
| 802 |
- f, err := os.OpenFile(filepath.Join(testDir, "test_file"), os.O_CREATE, 0644) |
|
| 803 |
- if err != nil {
|
|
| 806 |
+ if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
| 804 | 807 |
t.Fatal(err) |
| 805 | 808 |
} |
| 806 |
- f.Close() |
|
| 807 |
- if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
|
|
| 808 |
- t.Fatalf("build failed to complete: %s, %v", out, err)
|
|
| 809 |
- } |
|
| 810 |
- |
|
| 811 |
- deleteImages("testcopyimg")
|
|
| 812 |
- |
|
| 813 | 809 |
logDone("build - copy whole directory to root")
|
| 814 | 810 |
} |
| 815 | 811 |
|