-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Hello, I'm getting error whilst building a new image using Dockerfile for a Rust program.
Code in my "main.rs" as below:
use actix_web::{web, App, HttpResponse, HttpServer, Result};
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(||{
App::new()
.service(web::resource("/").route(web::get().to(index)))
})
.bind("0.0.0.0:4400")?
.run()
.await
}
async fn index() -> Result {
println!("Ch13 Docker Test");
Ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(include_str!("../static/index.html")))
}
Cargo.toml dependencies:
[dependencies]
actix-web = "2.0.0"
actix-rt = "1.0.0"
Dockerfile code:
FROM rust:1-slim-buster AS base
ENV USER = root
WORKDIR /code
#RUN cargo init
COPY Cargo.toml /code/Cargo.toml
#RUN cargo fetch
COPY src/ src/
CMD ["cargo", "test", "--offline"]
FROM base AS builder
RUN cargo build --release
FROM rust:1-slim-buster
COPY --from=builder /code/target/release/Ch13_docker_test /usr/bin/Ch13_docker_test
EXPOSE 4400
ENTRYPOINT ["/usr/bin/Ch13_docker_test"]
When I run "sudo docker build -t ch13_docker1g .", I get the following error on my terminal in Linux:
Step 8/12 : RUN cargo build --release
---> Running in 6b81f85ebb2b
Updating crates.io index
error: failed to get actix-rt
as a dependency of package Ch13_docker_test v0.1.0 (/code)
Caused by:
failed to load source for dependency actix-rt
Caused by:
Unable to update registry crates-io
Caused by:
failed to fetch https://github.com/rust-lang/crates.io-index
Caused by:
network failure seems to have happened
if a proxy or similar is necessary net.git-fetch-with-cli
may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
SSL error: received early EOF; class=Ssl (16); code=Eof (-20)
The command '/bin/sh -c cargo build --release' returned a non-zero code: 101
It is causing too much pain and delays, if it could be resolved please. As per above it says network failure but this is not true because the net is clearly working fine.