- 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 健康检查
28 lines
749 B
YAML
28 lines
749 B
YAML
networks:
|
|
rust-demo:
|
|
ipam:
|
|
driver: default
|
|
config:
|
|
- subnet: "172.31.2.0/24"
|
|
|
|
services:
|
|
demo:
|
|
image: registry.cn-shanghai.aliyuncs.com/odboy/kenaito:demo-rust # 镜像由 build.sh 构建
|
|
container_name: rust-demo
|
|
restart: unless-stopped
|
|
ports: # 映射端口
|
|
- "8088:8088"
|
|
environment: # 设置环境变量,相当于docker run命令中的-e
|
|
TZ: Asia/Shanghai
|
|
APP_PORT: "8088"
|
|
healthcheck:
|
|
# 运行镜像自带 net-tools,直接用端口探测,不额外安装 curl
|
|
test: ["CMD-SHELL", "netstat -tln | grep -q ':8088 '"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 5s
|
|
networks:
|
|
rust-demo:
|
|
ipv4_address: 172.31.2.20
|