Hi everyone!
This is a cross post of this StackOverflow thread. It might not have been the best place to put it as it's not receiving answers there.
I'm trying to build a docker container with some bleeding-edge crates that are available in git but not in crates.io. Moreover, those git dependencies depend on each other in a bit of a difficult way, so I have to use the patch
section of the Cargo.toml
file. Also, the project is in a workspace with multiple sub-crates.
The project compiles perfectly in local doing cargo build --bin frontend
, but it fails to compile inside docker, giving the following error:
STEP 13: RUN cargo vendor > .cargo/config
Updating git repository `https://github.com/GiGainfosystems/diesel`
error: failed to sync
Caused by:
failed to load pkg lockfile
Caused by:
failed to resolve patches for `https://github.com/rust-lang/crates.io-index`
Caused by:
failed to load source for dependency `diesel`
Caused by:
Unable to update https://github.com/GiGainfosystems/diesel?rev=0744b7e6e05582bf8fca21c0a5fbba08555abd94#0744b7e6
Caused by:
object not found - no match for id (0744b7e6e05582bf8fca21c0a5fbba08555abd94); class=Odb (9); code=NotFound (-3)
Error: error building at STEP "RUN cargo vendor > .cargo/config": error while running runtime: exit status 101
As far as I can tell, it seems that it cannot find the revision with that commit hash in that GitHub repo, but I can see it here, and it works perfectly outside of docker.
This is the patching configuration:
[patch.crates-io.diesel]
git = "https://github.com/GiGainfosystems/diesel"
rev = "0744b7e6e05582bf8fca21c0a5fbba08555abd94"
[patch.crates-io.diesel_derives]
git = "https://github.com/GiGainfosystems/diesel"
rev = "0744b7e6e05582bf8fca21c0a5fbba08555abd94"
[patch.crates-io.diesel_migrations]
git = "https://github.com/GiGainfosystems/diesel"
rev = "0744b7e6e05582bf8fca21c0a5fbba08555abd94"
Do you know if I need to provide any git configuration to cargo to access this repository? or what do you think it could be happening?
For reference, this is the dockerfile configuration:
FROM rustlang/rust:nightly-alpine3.12 AS rust_builder
WORKDIR /root/rustbuild/
RUN apk -U upgrade
RUN apk add libpq
COPY Cargo.lock .
COPY Cargo.toml .
RUN mkdir .cargo
COPY backend ./backend
COPY frontend ./frontend
COPY common ./common
COPY scheduler ./scheduler
COPY cli_utils ./cli_utils
RUN cargo vendor > .cargo/config
RUN cargo build --bin frontend
Note that I'm using rustlang/rust:nightly-alpine3.12
as the Rust container because I need a nightly compiler, and Alpine for multiple reasons, among them the fact that this also includes a NodeJS part that would also use the same Alpine version.
Let me know if you need any further information, or if you have any idea on where could the issue be.