—— 阿尔伯特·爱因斯坦

程序员の奇妙冒险

PythonDockerFastAPIPython
2026-01-15 08:39阅读:28评论:0

docker 部署Python FastAPI项目

FROM python:3.12-slim WORKDIR /app # 安装依赖 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # COPY app.py . # 暴露端口

1
2
3
4
5
6
7
8
9
10
11
12
FROM python:3.12-slim
WORKDIR /app
# 安装依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制代码
COPY app.py .
# 暴露端口
EXPOSE 8000
# 启动服务
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
评论(0)
暂无评论来抢沙发吧~