feat: 新增 rust 示例(标准库 TcpListener Web 服务,compile-rust / runtime-rust 两阶段构建)
- src/main.rs:零第三方依赖的 HTTP/1.1 服务,提供 /、/api/info、/health、 /api/hello、/page;App 用 Arc 共享后 clone 进 thread::spawn,保证 'static - Dockerfile:依赖预热层的桩产物放到 /tmp/deps-target,避免与正式编译 共用 /src/target 时被判定 up-to-date、把桩二进制拷进运行镜像;运行阶段 增加 grep 启动日志的构建期自检 - docker-compose.yml:固定 IP 172.31.2.20,端口 8088,netstat 健康检查
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "rust-demo"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
description = "Rust 简单 Web 示例,只用标准库 TcpListener,无第三方依赖"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[profile.release]
|
||||
# 产物更小、启动更快;运行镜像里只需这一个静态二进制
|
||||
opt-level = "z"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
panic = "abort"
|
||||
Reference in New Issue
Block a user