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