lnp_ml/docker-compose.yml
2026-01-26 11:08:57 +08:00

61 lines
1.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

services:
# FastAPI 后端服务
api:
build:
context: .
dockerfile: Dockerfile
target: api
container_name: lnp-api
# ports:
# - "8000:8000"
environment:
- MODEL_PATH=/app/models/final/model.pt
- DEVICE=cpu
volumes:
# 挂载模型目录以便更新模型
- ./models/final:/app/models/final:ro
- ./models/mpnn:/app/models/mpnn:ro
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# 如果有 NVIDIA GPU取消下面的注释
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
# Streamlit 前端服务
streamlit:
build:
context: .
dockerfile: Dockerfile
target: streamlit
container_name: lnp-streamlit
ports:
- "8501:8501"
environment:
# 连接到 API 服务(使用 Docker 内部网络)
- API_URL=http://api:8000
depends_on:
api:
condition: service_started
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8501/_stcore/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
networks:
default:
name: lnp-network