COPY failing: no such file or directory

Hello - I wonder can anyone help me with a problem that is perplexing me.

I have a Dockerfile, inside it, is something like this (using made up names for example):

COPY vendor/project-source /usr/src/project-source

Inside vendor/project-source there is a tree of folders like this:

project-source
|
-- module-one
|  |
|  -- code-files
|
-- module-two
|  |
|  -- code-files
|
-- build
   |
   --pre-built-binary

When the COPY runs, everything is copied across apart from the build folder and the binary.

So… I tried copying it explicitly…

COPY vendor/project-source /usr/src/project-source
COPY vendor/project-source/build/pre-built-binary /usr/bin/pre-built-binary

While deploying, this gives an error:

[main]     Step 11/29 : COPY vendor/project-source/build/pre-built-binary /usr/bin/pre-built-binary
[main]     lstat vendor/project-source/build/pre-built-binary: no such file or directory

I wondered was it being fussy because it had its executable flag set, so I did chmod -x but still the same result.

Just for clarity, the pre-built binary is a program designed to run on target architecture so it is a valid binary.

Can anyone tell me if I am doing something very wrong here? The file is clearly in the folder tree…

Hello,

Could you please create a sample project that reproduces this issue ?

Sorry, I just had a brain-wave that it was somehow ignoring the folder called build so I renamed it to not-build and it appears to have copied it across this time - is this potentially a dockerignore thing?

Most probably. Do you have a .dockerignore file ?

I don’t - does Balena use a default one?

Hi,
Is this issue happening while doing a git push or are you using the balena-cli ?
If you are using the balena-cli please also share the version that you are using.
Is there a chance that you have a .gitignore file in that folder that excludes vendor or build. If there is no .dockerignore file then the CLI uses the .gitignore file while building the image.

Kind regards,
Thodoris

I am away from my local device now to try the CLI but I do have a .gitignore with build in it so that could be disrupting things - I will check tomorrow.

As for my example, that was with git push balena master

If you are doing a git push and those folders are in .gitignore, then the likelyhood is that the files you added to your repository are not the ones that you expect. git push will use all the files tracked by git (.gitignore just tells what not to track automatically, if you manually add files that would otherwise would be ignored, git will track them just fine, and on the push they will be used. You can try to check whether your git tree does contain the files you expect or not.

For balena push, I think the same ignores are being used but without the chance of overrides like mentioned above for git. Thus would suggest to check out git and make sure that you have the files added to version control that you expect!

Let us know how it goes!

Thanks - I actually feel a bit stupid now but this was 100% the issue.

The project-source folder above inside vendor is a submodule on our private git - as the balena builder cannot access our git to get the submodule when I push it, I’ve have to keep copies of the submodules in the local repo…

To cut a pointlessly long story short, the gitignore in the main repo has extra stuff compared to the gitignore in the submodule and this has served to confuse me.

Thanks!