Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

782
Views
Pycharm debugger setup with FastApi and docker compose

I struggle to attach a debugger with Pycharm with a docker-compose fastAPI setup

docker-compose

    version: '3.8'

services:
  api:
    build: .
    volumes:
      - .:/app
    ports:
      - "8080:80"
    environment:
      - DATABASE_URL=postgresql://test_user:test_pwd@db:5432/test_db
    depends_on:
      - db
  
  db:
    image: postgres:13-alpine
    volumes:
      - postgres_data:/var/lib/postgres/data/
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=test_user
      - POSTGRES_PASSWORD=test_pwd
      - POSTGRES_DB=test_db

volumes:
  postgres_data:

dockerfile:

FROM tiangolo/uvicorn-gunicorn:python3.9

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

COPY ./app /app/app

CMD [ "/start-reload.sh" ]

I have set up a remote interpreter for docker-compose in pycharm When i start the application it works but breakpoint doest not

I try to setup python configurations: enter image description here

application start but breakpoint doest not too

If you have any suggestions? thank you

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This worked for me (from https://github.com/tiangolo/fastapi/issues/23#issuecomment-571602787):

The following works with the pycharm debugger with reload running in a docker-compose remote interpreter

from fastapi import FastAPI
import uvicorn

app = FastAPI()

@app.get("/")
def root():
    a = "a"
    b = "b" + a
    return {"hello world": b}


if __name__ == '__main__':
    uvicorn.run("main:app", host='0.0.0.0', port=8000, reload=True)

Notice the it's "main:app" and not app otherwise you get an error: WARNING: You must pass the application as an import string to enable 'reload' or 'workers'.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!