Last active
March 17, 2025 09:03
Run Odoo from container with debugger - VS Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
odoo: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
image: danieluac/odoo:dev-16.0 | |
container_name: odoo_16_dev | |
restart: always | |
ports: | |
- "8072:8072" | |
- "8069:8069" | |
- "5678:5678" | |
networks: | |
- odoo-network | |
volumes: | |
- odoo-web-data:/var/lib/odoo | |
- ./:/opt/odoo/addons/custom_addons | |
# - ./.config/odoo.conf:/etc/odoo/odoo.conf | |
- ./odoo-debug.sh:/odoo-debug.sh | |
entrypoint: ["/odoo-debug.sh"] | |
environment: | |
- ODOO_DEBUG=true | |
- ODOO_DEMO=false | |
- UPDATE_MODULES=base,mail | |
depends_on: | |
- db | |
db: | |
image: postgres:15.4 | |
container_name: odoo_db | |
restart: always | |
environment: | |
- POSTGRES_USER=odoo | |
- POSTGRES_PASSWORD=odoo | |
- POSTGRES_DB=postgres | |
- PGDATA=var/lib/postgresql/data/dbfiles | |
ports: | |
- "5432:5432" | |
networks: | |
- odoo-network | |
volumes: | |
- odoo-db-data:/var/lib/postgresql/data/dbfiles | |
volumes: | |
odoo-db-data: | |
odoo-web-data: | |
networks: | |
odoo-network: | |
driver: bridge | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM odoo:16.0 | |
USER root | |
RUN usermod -u 1000 odoo | |
COPY .config/requirements.txt /tmp/ | |
RUN pip install --no-cache-dir -r /tmp/requirements.txt | |
RUN mkdir -p /opt/odoo/addons/custom_addons | |
RUN chown odoo:odoo -R /opt/odoo/addons/custom_addons | |
ADD ./ /opt/odoo/addons/custom_addons | |
ADD ./odoo-debug.sh /odoo-debug.sh | |
RUN chmod 755 /odoo-debug.sh | |
RUN find /opt/odoo/addons/custom_addons -name "requirements.txt" -exec sh -c 'pip install -r "$0"' {} \; | |
USER odoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is a vs code launch.json, put in .vscode Directory | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "odoo", | |
"type": "debugpy", | |
"justMyCode": false, | |
"request": "attach", | |
"connect": { | |
"host": "localhost", | |
"port": 5678 | |
}, | |
"pathMappings": [ | |
{ | |
"localRoot": "${workspaceFolder}", | |
"remoteRoot": "/opt/odoo/addons/custom_addons" | |
} | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ARGS="--dev=xml" | |
if [ -n "$UPDATE_MODULES" ]; then | |
ARGS="$ARGS -u $UPDATE_MODULES" | |
fi | |
if [ "$ODOO_DEMO" = "false" ]; then | |
ARGS="--without-demo=True $ARGS" | |
fi | |
if [ -n "$DEFAULT_DB" ]; then | |
ARGS="$ARGS --database $DEFAULT_DB" | |
fi | |
if [ "$ODOO_DEBUG" = "true" ]; then | |
echo "CLICK F5 IN VS CODE, IT WILL START YOUR DEBUG" | |
python3 -m debugpy --listen 0.0.0.0:5678 --wait-for-client /usr/bin/odoo $ARGS "$@" | |
else | |
python3 /usr/bin/odoo $ARGS "$@" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; remove this line and put this file in .config directory | |
[options] | |
addons_path = /opt/odoo/addons/custom_addons | |
data_dir = /var/lib/odoo | |
db_user = odoo | |
db_password = odoo | |
db_host = odoo_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; remove this line and put this file in .config directory | |
debugpy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment