18 lines
383 B
Docker
18 lines
383 B
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# 先复制 requirements 以利用 Docker 缓存
|
|
COPY requirements.txt .
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 复制其余代码和数据(如果在后端的相对路径下需要读取)
|
|
COPY . .
|
|
|
|
# 暴露 FastAPI 使用的端口
|
|
EXPOSE 8000
|
|
|
|
# 启动 FastAPI
|
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|