tiangolo / uvicorn-gunicorn-fastapi-docker

Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python with performance auto-tuning.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Debug Mode

jonpeters opened this issue · comments

Is it possible to set the server into debug mode so that I can attach my IDE (VS Code) to a running container and step through code at development time?

I know that if I was doing this outside of a container, I could start the server explicitly, and provide the debug flag set, e.g.

uvicorn.run(app, host="0.0.0.0", port=8000, debug=True)

I couldn't figure out how to do this using this image.

Thank you!

VSCode (at least mine) has a FastAPI configuration built-in for running with breakpoints. If you go to the debug tab and select a configuration, FastAPI should be an option. You can also choose the option to create a launch.json folder such that when you run in debug with F5, it'll launch the server in a debug environment and it will stop at breakpoints, etc.

I know this isn't really anything to do with the docker container... but that's what I do when I need to stop through.