Za każdym razem kiedy uruchamiam debuggera dzieją się różne rzeczy, ale niekoniecznie takie, jakich oczekuję.
Zacznijmy od początku:

Uruchamiam projekt docker-compose up
Wchodzę na adres z localhosta, żeby sprawdzić czy cokolwiek działa - próba zalogowania - nie działa, backend leży.
Co zabawne kontener stoi bo mam włączone remote containers w vscode.
Pierwsza próba uruchomienia debuggera - zwrotka z debug console

Attached!
System check identified some issues:

WARNINGS:
workflow.State.additional_values: (fields.W904) django.contrib.postgres.fields.JSONField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
	HINT: Use django.db.models.JSONField instead.
Operations to perform:
  Apply all migrations: accounts, auth, contenttypes, files, mambu, otp_totp, sessions, token_blacklist, workflow, zoho
Running migrations:
  No migrations to apply.

i się wyłączyło. backend dalej leży.

Druga próba włączenia debuggera:

Attached!
System check identified some issues:

WARNINGS:
workflow.State.additional_values: (fields.W904) django.contrib.postgres.fields.JSONField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
	HINT: Use django.db.models.JSONField instead.
Zoho Configuration failed, check that you have all variables ZOHO_TOKEN_URL, ZOHO_REST_API_KEY, ZOHO_CURRENT_USER_EMAIL

i wyłączyło. backend wstał, da się zalogować na stronę i robić różne cyrki.

Trzecia próba włączenia debuggera kończy się okienkiem z napisem connect ECONNREFUSED 127.0.0.1:5678.

Jakieś tipy?

Pliki:

manage.py

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
 
 
def initialize_debugger():
    import debugpy
 
    debugpy.listen(("0.0.0.0", 5678))
    debugpy.wait_for_client()
    print('Attached!')
 
 
 
def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "capitalflow.settings")
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)
 
 
if __name__ == "__main__":
    initialize_debugger()
    main()

lokalny docker-compose.yml

version: "3.2"
 
services:
  backend:
    container_name: xxx
    build:
      context: ./backend
      dockerfile: ../build/backend.Dockerfile
    volumes:
      - ./backend:/opt/app
    command: ./run.sh
    ports:
      - "8000:8000"
      - "5678:5678"
    env_file:
      - build/.env-local
    links:
      - db:db
      - rabbit:rabbit
      - memcached:memcached
  celery:
    container_name: xxx
    restart: always
    build:
      dockerfile: ../build/backend.Dockerfile
      context: ./backend
    command: ./run_celery.sh
    env_file:
      - build/.env-local
    working_dir: /opt/app/
    volumes:
      - ./backend/:/opt/app
    links:
      - db:db
      - rabbit:rabbit
  frontend:
    container_name: xxx
    build:
      context: frontend
      dockerfile: ../build/frontend.Dockerfile
    environment:
      - BROWSER=none
      - CI=true
    volumes:
      - ./frontend/src/:/frontend/src
      - ./frontend/public/:/frontend/public
  nginx:
    container_name: xxx
    build:
      dockerfile: build/nginx.Dockerfile
      context: .
      args:
        REACT_APP_GOOGLE_ANALYTICS_TOKEN: $REACT_APP_GOOGLE_ANALYTICS_TOKEN
        REACT_APP_PAGESENSE_LINK: $REACT_APP_PAGESENSE_LINK
        REACT_APP_CHATBOT_TOKEN: $REACT_APP_CHATBOT_TOKEN
        REACT_APP_SENTRY_DSN: $REACT_APP_SENTRY_DSN
        REACT_APP_SENTRY_ENVIRONMENT: $REACT_APP_SENTRY_ENVIRONMENT
        REACT_APP_SENTRY_TRACES_SAMPLE_RATE: $REACT_APP_SENTRY_TRACES_SAMPLE_RATE
        REACT_APP_THIRD_PARTY_API_URL: $REACT_APP_THIRD_PARTY_API_URL
    ports:
      - "5000:80"
    depends_on:
      - backend
      - frontend
    env_file:
      - build/.env-local
    volumes:
      - ./build/nginx/nginx.conf:/etc/nginx.conf
  db:
    container_name: xxx
    image: postgres:12
    ports:
      - "5432:5432"
    restart: on-failure
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
  rabbit:
    container_name: xxx
    image: rabbitmq
    ports:
      - "5672:5672"
  memcached:
    container_name: xxx
    image: memcached
    ports:
      - "11211:11211"
    restart: always
  flower:
    image: mher/flower:0.9.5
    environment:
      - CELERY_BROKER_URL=amqp://capitalflow-rabbitmq//
      - FLOWER_PORT=8888
    ports:
      - 8888:8888

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "CF: Remote Attach",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}/backend",
                    "remoteRoot": "/opt/app/"
                }
            ],
            "django": true
        }
    ]
}