Closed csarn closed 2 years ago
Adding a +1 - I'm struggling with the same issue
+1 Also dealing with this issue
I'm not sure if this applies here, but you may want to try touching all the files before running the build and after COPYing them over. I had problems on another multi-staged dockerfile where seemingly up-date files were getting compilation errors from previous versions of the files or even from missing content in those files that was clearly there.
RUN touch Cargo.*
RUN find src/ -exec touch {} +
From: https://github.com/rust-lang/cargo/issues/2644#issuecomment-831062649
This looks like a zero2prod
issue of some type, and there are workarounds discussed at https://github.com/LukeMathWalker/cargo-chef/issues/43.
Thank you for letting me know!
What did you try to do?
I have this repository: https://git.christophsarnowski.com/cs/zero2prod I want to build a Docker image using this rust-musl-builder for static linking, and I have a multi-stage Dockerfile to take advantage of docker layer caching (using cargo-chef). The dockerfile is this: https://git.christophsarnowski.com/cs/zero2prod/src/commit/e8fd292295755e5ca037c6814f685c6692f6705c/Dockerfile-alpine
What happened?
The 'docker build --tag latest -f Dockerfile-alpine .' fails with the following error at the the 'builder' stage:
The "missing imports" do actually exist in the source tree. This happens locally and in a drone CI environment, and with an empty cache (all layers that should be cached did not exist before this failure. Repeated tries to build the image do use the cache, but fail at the same step with the same message.)
What did you hope to happen?
Successful build of the docker image. In contrast, the other Dockerfile: https://git.christophsarnowski.com/cs/zero2prod/src/commit/e8fd292295755e5ca037c6814f685c6692f6705c/Dockerfile-debian
with almost exactly the same commands, but based on the official rust image, succeeds in building the image, as does a local build outside docker.
Does
./test-image
work?I cancelled it about 10 minutes in, it did not show any failures that far. I can report back with a full run. Also more importantly, building the same application with rust-musl-builder in less stages without cargo-chef worked fine. It is sufficient to remove the "planner" and "cacher" stages and the "COPY --from=cacher... " lines.
Additional information
I will also post an issue in the cargo-chef repo, as I am not sure which side contains the bug leading to this failure. EDIT: The issue for cargo-chef is here: https://github.com/LukeMathWalker/cargo-chef/issues/43