我在 Rust + Actix-web 中有一个 hello world web 项目。我有几个问题。首先是代码的每次更改都会导致重新编译整个项目,包括下载和编译每个 crate。我想像在正常开发中一样工作 - 这意味着缓存编译的 crate 并且只重新编译我的代码库。第二个问题是它不会暴露我的应用程序。无法通过网络浏览器访问
Dockerfile:
FROM rust
WORKDIR /var/www/app
COPY . .
EXPOSE 8080
RUN cargo run
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml:
version: "3"
services:
app:
container_name: hello-world
build: .
ports:
- '8080:8080'
volumes:
- .:/var/www/app
- registry:/root/.cargo/registry
volumes:
registry:
driver: local
Run Code Online (Sandbox Code Playgroud)
主.rs:
extern crate actix_web;
use actix_web::{web, App, HttpServer, Responder};
fn index() -> impl Responder {
"Hello world"
}
fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(web::resource("/").to(index)))
.bind("0.0.0.0:8080")?
.run()
}
Run Code Online (Sandbox Code Playgroud)
货物.toml:
[package]
name = …Run Code Online (Sandbox Code Playgroud) 虽然我已经看到rustc直接使用输出程序集的文档,但必须手动提取Cargo使用的命令并编辑它们来编写程序集是很繁琐的.
有没有办法运行编写汇编文件的货物?