Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrypoint command missing on django app #2334

Closed
general03 opened this issue Sep 20, 2020 · 7 comments
Closed

Entrypoint command missing on django app #2334

general03 opened this issue Sep 20, 2020 · 7 comments
Labels

Comments

@general03
Copy link

Hi,

I configured my launch.json file in my project

{
    "configurations": [
        {
            "name": "Docker: Python - Django",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "python": {
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}/app",
                        "remoteRoot": "/usr/src/app"
                    }
                ],
                "port": 8000,
                "projectType": "django",
                "django": true,
            },
        }
    ]
}

With this task.json


{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "docker-build",
            "label": "docker-build",
            "platform": "python",
            "dockerBuild": {
                "tag": "myapp:latest",
                "dockerfile": "${workspaceFolder}/app/Dockerfile",
                "context": "${workspaceFolder}",
                "pull": true
            }
        },
        {
            "type": "docker-run",
            "label": "docker-run: debug",
            "dependsOn": [
                "docker-build"
            ],
            "python": {
                "args": [
                    "runserver",
                    "0.0.0.0:8000"
                ],
                "file": "manage.py"
            },
            "dockerRun": {
                "ports": [
                    {
                        "hostPort": 8000,
                        "containerPort": 8000
                    }
                ],
                "volumes": [
                    {
                        "containerPath": "/usr/src/app",
                        "localPath": "${workspaceFolder}/app"
                    }
                ]
            }
        }
    ]
}

The build works well without error and my container is up.
But when the build run is executed it miss the entrypoint command like I put in the previous file python manage.py runserver 0.0.0.0:8000, I see in the console this automatic command

> docker run -dt -P --name "myapp-dev" --label "com.microsoft.created-by=visual-studio-code" -v "/home/general03/.vscode/extensions/ms-python.python-2020.8.109390/pythonFiles/lib/python/debugpy:/debugpy:ro" --entrypoint "python" "myapp:latest" <

What I miss ??

Thanks

Docker extension 1.6.0
Python extension v2020.8.109390

Version: 1.49.1
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-16T23:23:33.049Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 4.19.0-10-amd64

@bwateratmsft
Copy link
Collaborator

@general03 This is by design. The docker-run tasks are meant for debugging; in order to debug the app at launch time--instead of attaching later--it is necessary to start the container without starting the app inside of it. So, we use python as the entrypoint, so that the container stays running but isn't doing anything. Then, when the debug task resolves, it is handed over to the Python extension's debugger, which will actually launch the app inside the container, with the debugger attached from the very beginning. The arguments in the docker-run task's python section are used as the arguments to launch it.

The debugging flow is covered in https://code.visualstudio.com/docs/containers/debug-python which is also linked in the Python Dockerfile.

@general03
Copy link
Author

Thanks @bwateratmsft

But I don't understand why my breakpoint is not reachable, my container started right but nothing append (error or something else). The blue loading run in the runbar without end
I also check the output log in VSCode without error found

image

@bwateratmsft
Copy link
Collaborator

bwateratmsft commented Sep 22, 2020

Is there any output in the Terminal window for "Python Debug Console":
image

Or in the Output window from Python:
image

Or the debug console:
image

This sounds like #2313, that user was also on Linux.

@general03
Copy link
Author

general03 commented Sep 22, 2020

@bwateratmsft you are a genius ...
The #2313 help me to launch the debug right

Thanks again

@bwateratmsft
Copy link
Collaborator

@general03 Did you also need to add "debugAdapterHost" to your launch config?

@general03
Copy link
Author

Yes, because I'm on linux ?

@bwateratmsft
Copy link
Collaborator

Gotcha. Yeah, we definitely didn't intend for that to be a necessary step. I've fixed the code path in #2331; in the future adding that "debugAdapterHost" will not be necessary.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants