DEV Community

Discussion on: How to remote debugging Odoo Docker images (Python based framework)

Collapse
 
kerbrose profile image
Khaled Said

Hello Farid
please note that when using debugpy to debug python apps (Odoo server in our case). you're overriding the entrypoint.sh of the container. by other words you are starting the debugpy server inside of the container instead of Odoo server.
take a look at the following command:

/usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
Enter fullscreen mode Exit fullscreen mode

/usr/bin/python3 -m debugpy: here you ask python to start module debugpy
--listen 0.0.0.0:8888: here you aske debugpy server to listen 0.0.0.0:8888
/usr/bin/odoo: here you ask debugpy to start a python process (in our case odoo server)
--db_user=odoo --db_host=db --db_password=odoo: here, are the rest of odoo cli
so if you are debugging a different python file named tic_tac_toe.py, the command would be something like

python -m debugpy tic_tac_toe.py
Enter fullscreen mode Exit fullscreen mode

the first portion of the docker-compose command:

docker-compose run --rm -p 8888:8888 -p 8869:8069 {DOCKER IMAGE[:TAG|@DIGEST]}
Enter fullscreen mode Exit fullscreen mode

it is asking docker-compose to map ports of the host to ports of the container & running the image. please note that you have to replace {DOCKER IMAGE[:TAG|@DIGEST]} with image information. you can get such information from command docker images -a

~ → docker images -a
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
odoo         14        27c34e85682c   2 weeks ago   1.24GB
odoo         14.0      27c34e85682c   2 weeks ago   1.24GB
postgres     13        a6cd86e1dfce   3 weeks ago   314MB
Enter fullscreen mode Exit fullscreen mode

so in my case it could be

docker-compose run --rm odoo:13
# or 
docker-compose run --rm a6cd86e1dfce
Enter fullscreen mode Exit fullscreen mode