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'

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐