Reputation: 740
Hi this is somewhat similar to this question but nothing there about docker containers
I am using a mac so I started using docker since it's more convenient on macOS Microsoft visual studio code has may feature a full development environment
It has an extension from MS Remote - Containers with should make easier
This is my docker-compose.yml
version: '2'
services:
db:
image: 'postgres:11'
environment:
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- POSTGRES_DB=postgres
restart: always
volumes:
- './postgresql:/var/lib/postgresql/data'
pgadmin:
image: dpage/pgadmin4
depends_on:
- db
ports:
- '5555:80'
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
volumes:
- './pgadmin:/var/lib/pgadmin'
odoo13:
image: 'odoo:13'
depends_on:
- db
ports:
- '10013:8069'
tty: true
command: '-- --dev=reload'
volumes:
- './addons:/mnt/extra-addons'
- './enterprise:/mnt/enterprise-addons'
- './config:/etc/odoo'
restart: always
Upvotes: 3
Views: 3408
Reputation: 1185
In order to understand how remote debugging
works for all python services or apps which based on it such as Odoo, Flask, Django, Web2py or whatever. you have to understand three different concepts the docker container, the debugger, the python app server (in our case it's Odoo). so in many cases, when running Odoo from docker it is like the following image:
and what you really need to be able to debug would be like the following image:
please note the difference:
debugpy
& vice versa (you could also use 2 ports by the way).Dockerfile
. with debugging, you modify the entrypoint to be debugpy
. which will be responsible for running Odooso to debug Odoo you will be doing as following:
Edit your docker.dev
file & insert RUN pip3 install -U debugpy
. this will install a python package debugpy
instead of the deprecated one ptvsd
because your vscode (local) will be communicating with debugpy (remote) server of your docker image using it.
Start your container. you will be starting the python package that you just installed debugpy
. it could be as next command from your shell.
docker-compose run --rm -p 8888:8888 -p 8869:8069 {DOCKER IMAGE[:TAG|@DIGEST]} /usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
port
will be related to odoo server. debugServer
will be the port for the debug server{
"name": "Odoo: Attach",
"type": "python",
"request": "attach",
"port": 8869,
"debugServer": 8888,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/mnt/extra-addons",
}
],
"logToFile": true
}
Upvotes: 3