astral-sh / uv-docker-example

An example of using uv in Docker images
80 stars 11 forks source link

🤔 Deployment guides for beginner #21

Closed jd-solanki closed 2 months ago

jd-solanki commented 2 months ago

Hi 👋🏻

I used uv docker example and it works fine. However, I would like to understand what is needed to deploy fastapi app from docker using UV?

In example, there's fastapi dev which runs fastapi in dev mode so does just switching to fastapi run will make it for production?


I'm asking because when I run fastapi in production it works on https but assets generated using url_for still generates http URL 🤷🏻

I'll be thankful if someone can help me deploy FastAPI app that uses UV & docker. I'm using AWS EC2 instance & nginx for serving FastAPI app.

zanieb commented 2 months ago

Yeah now that we did https://github.com/astral-sh/uv-docker-example/pull/17 the only thing you should need to do for production is switch to the run command instead of dev. You could also consider the multistage image.

zanieb commented 2 months ago

I'm not sure about the url_for and HTTP/S behavior. cc @tiangolo

jd-solanki commented 2 months ago

Thanks @zanieb for your help in the uv community 🙏🏻

Also adding this meta tag does the trick along with your inputs & this FastAPI docs.

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">