Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

770
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda