Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

777
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda