Open amab8901 opened 7 months ago
Can you post the full Dockerfile that fails for you?
Dockerfile contents:
FROM rust:1.75.0 as chef
RUN cargo install cargo-chef --locked
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
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin nice
FROM debian:bookworm-slim AS runtime
WORKDIR /app
RUN apt update
RUN apt install openssl -y
COPY --from=builder /app/target/release/nice .
CMD ./nice
The error is reproduced via docker build .
in the repo root directory. The error is reproducible when the repo is minimalistic with only fn main() {}
in the main.rs
. I have an outer Cargo.toml
like this:
cargo-features = ["codegen-backend"]
[profile.dev]
codegen-backend = "cranelift"
[workspace]
resolver = "2"
members = ["nice"]
Directory tree looks like this:
The inner Cargo.toml
has the following content:
[package]
name = "nice"
[dependencies]
.cargo/config.toml
:
[unstable]
codegen-backend = true
[profile.dev]
codegen-backend = "cranelift"
It looks like you are trying to use cg_clif on stable. It is currently only available on nightly. In addition you need to install the rustc-codegen-cranelift-preview component. I don't know if the container for rustc nightly has a way to install it, but if you were to use rustup, you did do rustup override set nightly; rustup component add rustc-codegen-cranelift-preview
.
It looks like you are trying to use cg_clif on stable. It is currently only available on nightly. In addition you need to install the rustc-codegen-cranelift-preview component. I don't know if the container for rustc nightly has a way to install it, but if you were to use rustup, you did do
rustup override set nightly; rustup component add rustc-codegen-cranelift-preview
.
I added your suggestions to my Dockerfile and it fixed it. Thanks 😄 Maybe you can add this in the README file?
Happy to hear you managed to get it working! The nightly requirement and the need to install the rustc-codegen-cranelift-preview component is documented at https://github.com/rust-lang/rustc_codegen_cranelift#download-using-rustup Do you have any suggestions on how to make it clearer?
Happy to hear you managed to get it working! The nightly requirement and the need to install the rustc-codegen-cranelift-preview component is documented at https://github.com/rust-lang/rustc_codegen_cranelift#download-using-rustup Do you have any suggestions on how to make it clearer?
Maybe create a Docker title in that README.md that explains the fact that you need to add
rustup override set nightly
rustup component add rustc-codegen-cranelift-preview
(or something like this) to Dockerfile in order for Docker to work with Cranelift. It's probably obvious to someone experienced with Docker, but Docker is something junior devs usually don't have mastery of (I'm late-junior or early-intermediate) so this is likely to be an issue many devs would stumble on if it isn't explicitly stated what needs to be put in Dockerfile to make it work with Docker.
fwiw I think this isn't necessary to be documented in the readme, this is pretty obvious that to use cranelift in docker that it is necessary to use the same install steps as everywhere else.
Cranelift is currently incompatible with the following Docker command (at least in my case):
docker-compose up -d --build
I get this error message:
Would be awesome if u fix it!