FastAPI 容器化UV部署
【代码】FastAPI 容器化UV部署。
·
main.py
from fastapi import FastAPI
import uvicorn
app=FastAPI()
@app.get('/')
def index():
return 'Hello FastAPI'
if __name__ == "__main__":
uvicorn.run(app,host="0.0.0.0")
Dockerfile
FROM docker.1ms.run/python:3.12-slim
RUN pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY unisee /app/unisee
WORKDIR /app/unisee
RUN uv sync
EXPOSE 8000
ENTRYPOINT ["uv","run","main.py"]
podman build -t test:1.0 .
podman run --rm --name test p 8001:8000 test:1.0
curl http://127.0.0.1:8001/
>>>'Hello FastAPI'
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)