Setup FastAPI Debugger in PyCharm With Docker

The key is running only 1 worker when start uvicorn

Content

For local Python app development, use a Docker container for non-application services like databases, Redis, etc. If all of your services are running in containers, you SHOULD use …


This content originally appeared on DEV Community and was authored by whchi

The key is running only 1 worker when start uvicorn

Content

For local Python app development, use a Docker container for non-application services like databases, Redis, etc. If all of your services are running in containers, you SHOULD use remote debug.

If all of your services are run in container you SHOULD use remote debug

0. Dockerfile

Here, I will use docker-compose as example

  • docker-compose.debug.yml
version: "3.8"
services:
  pgsql:
    image: postgres:13
    restart: unless-stopped
    environment:
        - POSTGRES_HOST_AUTH_METHOD=trust
        - POSTGRES_USER=root
        - POSTGRES_PASSWORD=
        - POSTGRES_DB=postgres
    volumes:
      - postgres:/var/lib/postgresql/data
    ports:
      - '5432:5432'
    privileged: true
volumes:
  postgres:

1. Setup Run/Debug configurations

It's located in the top-right corner.
setup

2. Setup local running configuration

Choose "FastAPI" for the running configuration.

remember to set --workers=1

setup

3. Setup container running configuration

Choose Docker Compose for your configuration.

setup

4. Add local configuration

Under "Before launch" settings, add your local running configuration.

setup

Complete setup
setup

5. Start debugger as a happy debugger

setup


This content originally appeared on DEV Community and was authored by whchi


Print Share Comment Cite Upload Translate Updates
APA

whchi | Sciencx (2023-06-03T09:24:03+00:00) Setup FastAPI Debugger in PyCharm With Docker. Retrieved from https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/

MLA
" » Setup FastAPI Debugger in PyCharm With Docker." whchi | Sciencx - Saturday June 3, 2023, https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/
HARVARD
whchi | Sciencx Saturday June 3, 2023 » Setup FastAPI Debugger in PyCharm With Docker., viewed ,<https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/>
VANCOUVER
whchi | Sciencx - » Setup FastAPI Debugger in PyCharm With Docker. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/
CHICAGO
" » Setup FastAPI Debugger in PyCharm With Docker." whchi | Sciencx - Accessed . https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/
IEEE
" » Setup FastAPI Debugger in PyCharm With Docker." whchi | Sciencx [Online]. Available: https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/. [Accessed: ]
rf:citation
» Setup FastAPI Debugger in PyCharm With Docker | whchi | Sciencx | https://www.scien.cx/2023/06/03/setup-fastapi-debugger-in-pycharm-with-docker/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.