Description of problem: Version-Release number of selected component (if applicable): Openshift v3.5.5.15 How reproducible: Always Steps to Reproduce: 1. # oc new-project 01868320 2. # mkdir -p build/dir1/dir2/dir3/ 3. # touch build/dir1/dir2/test.txt 4. # oc new-build build/. --strategy=docker -D $'FROM registry.access.redhat.com/rhel7 \nCOPY build/ /opt/' --name='testbc' 5. oc start-build testbc --from-dir=. -Fw 6. oc run -i test-img --image=172.30.247.236:5000/01868320/testbc:latest $ sh-4.2$ ls -al /opt/dir1/dir2/ total 0 drwxr-xr-x. 2 root root 22 Jun 13 08:08 . drwxr-xr-x. 3 root root 18 Jun 13 08:08 .. -rw-r--r--. 1 root root 0 Jun 13 08:08 test.txt Actual results: dir3 (which is empty) is not included in the image Expected results: dir3 (and any empty directory) is included in the image Additional info: The same procedure works correctly on docker, and the empty directories are included in the image: # cat Dockerfile FROM registry.access.redhat.com/rhel7 COPY build/ /opt/ # docker build -t test . # docker run -it test # ls -l /opt/dir1/dir2/ total 0 drwxr-xr-x. 2 root root 6 Jun 13 07:25 dir3 -rw-r--r--. 1 root root 0 Jun 13 07:25 test.txt
this is an issue with how we tar up the local content to send it to the build. Currently this code only includes files, not dirs, in the tar: https://github.com/openshift/origin/blob/master/vendor/github.com/openshift/source-to-image/pkg/tar/tar.go#L207 I'm not sure if there's a historical reason for that, or it was inadvertent.
Cesar any chance you know if there's a specific reason we do it that way? Or Michal?
I don't remember a specific reason for only including files and not directories. This is definitely not a regression though.
Ben, isn't it because of GIT? I do remember git omits the empty directories. To workaround this bug, can you just drop a .gitignore to that empty folder?
@Michal no, has nothing to do w/ git, it's the tar logic i pointed to in comment 1. This also affects binary builds (no git involved).
https://github.com/openshift/source-to-image/pull/763 https://github.com/openshift/origin/pull/14961
https://github.com/openshift/origin/pull/14992
verified openshift v3.6.133 kubernetes v1.6.1+5115d708d7 # oc run -i test-img1 --image=docker-registry.default.svc:5000/dyan5/testbc:latest If you don't see a command prompt, try pressing enter. ls -al /opt/dir1/dir2/ total 0 drwxr-xr-x. 3 root root 34 Jul 5 09:52 . drwxr-xr-x. 3 root root 18 Jul 5 09:52 .. drwxr-xr-x. 2 root root 6 Jul 5 09:52 dir3 -rw-r--r--. 1 root root 0 Jul 5 09:52 test.txt