Problem with COPY -- source not where I think it is

Hi all

I have repo that deploys fine via Balena Cloud but I’ve hit an odd issue when via my instance of open balena (which I’ve used fine for other repos).

Error is:
$ balena deploy BaleanBeagleGost --logs --source . --emulated --build

main Step 6/13 : RUN [“/tmp/qemu-execve”,“-execve”,“/bin/sh”,“-c”,“cmake ./monitor/”]
[Build] main —> Running in 6366f8e774f3
[Build] main CMake Error: The source directory “/usr/src/app/monitor” does not exist.
[Build] main Specify --help for usage, or press the help button on the CMake GUI.
[Build] Built 1 service in 0:02
[Error] Deploy failed
The command ‘/tmp/qemu-execve -execve /bin/sh -c cmake ./monitor/’ returned a non-zero code: 1

My repo is structure as:

Dockerfile
├── monitor
│ ├── CMakeLists.txt
│ ├── DHT11
│ │ ├── CMakeLists.txt
│ │ ├── *.c
│ │ └── *.h
│ ├── input.json
│ ├── IO
│ │ ├── CMakeLists.txt
│ │ ├── *.c
│ │ └── *.h
│ ├── main.c

Dockerfile contents:
FROM balenalib/beaglebone-black-golang:latest-build AS build

Install build tools and remove apt-cache afterwards

RUN apt-get -q update && apt-get install -yq --no-install-recommends
build-essential
cmake
libcurl4-openssl-dev
&& apt-get clean && rm -rf /var/lib/apt/lists/*

Build C application

WORKDIR /usr/src/app
COPY . /usr/src/app

RUN mkdir /usr/src/app/build
WORKDIR /usr/src/app/build
RUN cmake …/monitor
RUN make

Switch to operational container

FROM balenalib/beaglebone-black-debian:stretch
COPY --from=build /usr/src/app/build/monitor monitor
COPY --from=build /usr/src/app/monitor/* ./

#switch on systemd init system in container
ENV INITSYSTEM on

Run binary on container startup

CMD ./monitor

Any ideas?

Anyone?
Some more experimenting revealed the same issues as here but I’m not using windows ( using Ubuntu)…

(Copy of source is failing as source isn’t in the temp docker build dir)

@r4space, I’ve noticed the Dockerfile contents reads "RUN cmake …/monitor" – I guess it was just a copy-and-paste formatting issue, but it should probably have been "RUN cmake ../monitor" instead. Given that the error message complains that "The source directory “/usr/src/app/monitor” does not exist", I suggest you add a couple of lines as follows, to double check that the working directory looks/behaves like you would expect at that point:

RUN mkdir /usr/src/app/build
WORKDIR /usr/src/app/build
RUN pwd && ls -lR
RUN pwd && ls -lR ../
RUN cmake ../monitor

Hi

Thanks for taking a look!

Unsure how/what given deployed fine elsewhere but sorry for the redherring - gitignore was the culprit :confused:

@pdcastro Does balena cml look at gitignore for anything? Super odd cause I deployed my code from laptop to server just fine with git but for some reason it appears as if balena deploy misunderstood my gitignore.

In brief repo on laptop:
monitor //a directory
monitor //executable IDE created
gitignore had a line in it “monitor” to ignore the executable but monitor directory and contents were considered part of repo and tracked just fine

Repo on server pulled from gitlab contained monitor director and code and the same gitignore and as expected no executuable called monitor.

But, it appears that balena deploy command ignored my monitor directory until I removed the line in gitignore “monitor”

:?

@r4space, the balena CLI (push, build, deploy commands) looks at the gitignore and dockerignore files, yes. There are some behaviours that some consider a feature, others consider a bug. Some of those, and some workarounds, are discussed in this GitHub issue:

1 Like

Good to know, lesson learnt :slight_smile: