Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cargo build on MacOS(M1), it be killed when Updating crates.io index #151

Open
ipconfiger opened this issue Mar 8, 2023 · 5 comments
Assignees
Labels

Comments

@ipconfiger
Copy link

What did you try to do?

alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:latest'

rust-musl-builder cargo build --release

What happened?

╰─$ rust-musl-builder cargo build --release
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Updating crates.io index
%

I run docker run directly, and got:

docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:latest 137 ↵
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

rust@9e4d8a501d78:/src$ ls
Cargo.lock Cargo.toml logs release.sh src target
rust@9e4d8a501d78:
/src$ cargo build
Updating crates.io index
Killed Fetch [======> ] 30.75%, 2.60MiB/s

What did you hope to happen?

finish building

Additional information

@nicksrandall
Copy link

I'm seeing the same issue

@John-Bob-DIRIENZO
Copy link

I'm currently having the same issue :/

@letsgetrusty
Copy link

I got a static binary build to work on my M1 mac using the rust-musl-builder image.

Here is my Dockerfile:

FROM messense/rust-musl-cross:x86_64-musl as chef

# remove the line below when switching to >=rust:1.70.0. sparse mode is planned to be the default in Rust 1.70.0
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
ENV SQLX_OFFLINE=true

RUN cargo install cargo-chef
WORKDIR /rust-api-deployment-example

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /rust-api-deployment-example/recipe.json recipe.json
RUN rustup target add x86_64-unknown-linux-musl
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl

# We do not need the Rust toolchain to run the binary!
FROM scratch
COPY --from=builder /rust-api-deployment-example/target/x86_64-unknown-linux-musl/release/rust-api-deployment-example /usr/local/bin/rust-api-deployment-example
EXPOSE 3000
ENTRYPOINT [ "rust-api-deployment-example" ]

@John-Bob-DIRIENZO
Copy link

@letsgetrusty Thanks a lot ! Just so you know, I jumped on the Rust train 2 days ago mainly thanks to your videos so I wanted to address a massive thank you for your work to welcome new rustacean on board.
Best regards,

@ahctangU
Copy link

@letsgetrusty I did not expect to see this name here. However, I just wanted to say, you are seriously the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants