Closed EvilWatermelon closed 1 year ago
Can you replacing
RUN cargo build --release
with
RUN cargo build --release --bin isumis
?
I also started getting this recently. I was able to create a minimal example for you here.
To test I ran the build:
cd cargo-chef-demo
docker build -t test .
Then shell into the container to run the bin:
docker run -it test ash
./chef-builds
It should print "Hello,world!", but just exits.
Let me know if I can do anything to help
@lanklaas it doesn't print "Hello,world!".
cargo-chef-demo$ sudo docker run -it test ash
/app $ ./chef-builds
/app $
@LukeMathWalker I added it but that didn't fixed it.
Sorry, think I worded it wrong. The example I gave is an example of the broken one. So it not printing Hello,world!
is the problem. I pushed another dockerfile to the repo to show you the working example (without using cargo-chef). If you pull again you can build it like this:
docker build -f working.Dockerfile -t wtest .
Then run it:
docker run -it wtest ash
./chef-builds
This one prints Hello,world!
An interesting thing I noticed was that the binary file sizes differs just a little:
Broken Size:
/app $ ls -l
total 4372
-rwxr-xr-x 1 root root 4475024 Aug 18 06:11 chef-builds
Working size
/app $ ls -l
total 4384
-rwxr-xr-x 1 root root 4481912 Aug 18 06:56 chef-builds
And how this solve my problem?
ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount1208140388/working.Dockerfile: no such file or directory
I run into this as well. After a whole day of tinkering with things, I was able to narrow down the issue to cargo-chef. Removing it from the Dockerfile revealed the real issue, I had mistakenly excluded some necessary files through .dockerignore
entries (including the main.rs
). And yet, with cargo chef cook
in the recipe, the Dockerfile compiled and completed without an issue! Fixing the ignore entries solved everything and hopefully, this case helps to narrow down the issue.
@lanklaas: pretty sure the issue is due to a swapped statement in your Dockerfile, see https://github.com/lanklaas/cargo-chef-demo/pull/1 I'm not at my laptop to confirm it works, but I'm fairly confident.
@LukeMathWalker thanks, Yes I forgot I swapped those because I got version issues before the swap. I added 2 branches on the repo correct-copy-order which is the same fix as your PR, and workspace in which I changed the repo to a cargo workspace to fix the error in correct-copy-order
, just in case it helps someone else here.
I tracked down the original issue that caused me to do the swap, but it is not related to this issue. I will investigate and report it if I have some more concrete info
Perfect, I'll close the issue then 👍🏻
I recently changed my Dockerfile to
cargo chef
and after it runs successfully then myactix-web
program stops immediatly withexit code 0
. What do I have to change in my Dockerfile?