Dockerfile 662 B

1234567891011121314151617181920212223
  1. # 基础镜像
  2. FROM python:3.11-alpine
  3. # 设置工作目录
  4. WORKDIR /app
  5. # 只复制当前目录(曹航/4)及其子目录到容器
  6. COPY . /app
  7. # 安装依赖(假设有 requirements.txt 或 pyproject.toml)
  8. # 优先使用 requirements.txt
  9. RUN if [ -f requirements.txt ]; then \
  10. pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt; \
  11. elif [ -f pyproject.toml ]; then \
  12. pip install --upgrade pip && pip install --no-cache-dir .; \
  13. fi
  14. # 暴露端口
  15. EXPOSE 8000
  16. # 启动FastAPI服务(根据实际入口文件调整)
  17. CMD ["uvicorn", "sse_fastapi:app", "--host", "0.0.0.0", "--port", "8000","--reload"]