Hi there!
I’m trying to deploy a Rust Actix app that is within a workspace using a lib crate I created. I followed this guide but got this error during the build:
------
> [builder 2/4] RUN cargo chef cook --release --recipe-path recipe.json:
0.239 Updating crates.io index
0.253 error: failed to get `common_lib` as a dependency of package `server_app v0.0.1 (/app)`
0.253
0.253 Caused by:
0.253 failed to load source for dependency `common_lib`
0.253
0.253 Caused by:
0.253 Unable to update /lib
0.253
0.253 Caused by:
0.253 failed to read `/lib/Cargo.toml`
0.253
0.253 Caused by:
0.253 No such file or directory (os error 2)
0.254 thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-chef-0.1.67/src/recipe.rs:218:27:
0.254 Exited with status code: 101
0.254 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
------
My folder structure is:
/rust
----/lib
--------Cargo.toml
----/server
--------/src/main.rs
--------Cargo.toml
--------Dockerfile
--------fly.toml
And the Cargo.toml
in /rust/server
contains:
[dependencies]
common_lib = { path = "../lib" }
The generated Dockerfile is:
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --bin server_app
# We do not need the Rust toolchain to run the binary!
FROM debian:bookworm-slim AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/server_app /usr/local/bin
ENTRYPOINT ["/usr/local/bin/server_app"]
Have you some hints on this?