零度星河
返回
发布于 更新于 阅读:156 评论: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
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)
暂无评论 来抢沙发吧~

目录

SpringWonderland

探索 Spring 生态的奇妙世界

2026-01-15 08:39

我的标签

随笔分类

归档

查看完整归档 →