From 3eb79e24314aa9923e5d9ea40abb5730175e3ab0 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Mon, 17 Aug 2026 13:57:25 +0200 Subject: [PATCH] [IMP] docker-compose: host paths in .env, override merged in The OCA sources living outside this repo were mounted from a hardcoded /media/snt/data/odoo in a local, untracked docker-compose.override.yml. The host root now comes from ODOO_SRC in .env (gitignored, .env.example added), so the mounts can live in docker-compose.yml itself and be shared. Also parameterized: the published ports (ODOO_HTTP_PORT / ODOO_LONGPOLLING_PORT) and the in-container addons path (ODOO_ADDONS_PATH), the latter being the single source of truth for the `command` and for manual `docker-compose run odoo odoo ...` invocations. Missing variables fail with an explicit message instead of mounting empty paths. `docker-compose config` resolves exactly as before. Co-Authored-By: Claude Opus 5 --- .env.example | 22 +++++++++++++ docker-compose.yml | 32 +++++++++++++++++-- pos_payment_method_cashdro_fix/README.rst | 4 +-- .../readme/USAGE.rst | 4 +-- 4 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..91608fd --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +# Local environment for docker-compose. Copy to `.env` and adjust the paths: +# +# cp .env.example .env +# +# `.env` is gitignored: every developer points these at their own checkouts. +# docker-compose reads it automatically. For manual `docker-compose run` calls +# that need $ODOO_ADDONS_PATH in the shell, load it first: +# +# set -a; . ./.env; set +a + +# Host directory holding the read-only Odoo/OCA sources (OCB + the OCA repos +# listed in oca_dependencies.txt). Each repo is mounted at /mnt/oca/. +ODOO_SRC=/media/snt/data/odoo + +# Host ports published by the odoo service (web / longpolling). +ODOO_HTTP_PORT=8069 +ODOO_LONGPOLLING_PORT=8072 + +# Addons path *inside* the container. Single source of truth: used by the +# `command` in docker-compose.yml and by manual `docker-compose run` +# invocations (`odoo --addons-path=$ODOO_ADDONS_PATH ...`). +ODOO_ADDONS_PATH=/mnt/extra-addons,/mnt/oca/account-invoice-reporting,/mnt/oca/account-invoicing,/mnt/oca/bank-payment,/mnt/oca/community-data-files,/mnt/oca/l10n-spain,/mnt/oca/pos,/mnt/oca/product-attribute,/mnt/oca/purchase-workflow,/mnt/oca/sale-workflow,/mnt/oca/stock-logistics-workflow,/usr/lib/python3/dist-packages/odoo/addons diff --git a/docker-compose.yml b/docker-compose.yml index c83e9da..7e207f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,14 @@ +# Host-specific values (paths, ports) live in `.env` — see `.env.example`: +# +# cp .env.example .env +# +# Note: `docker-compose run odoo odoo ...` replaces the `command` below, so the +# addons path has to be repeated there. Load `.env` into the shell first: +# +# set -a; . ./.env; set +a +# docker-compose run --rm odoo odoo -c /etc/odoo/odoo.conf \ +# --addons-path=$ODOO_ADDONS_PATH \ +# -d odoo -u --test-enable --stop-after-init services: db: image: postgres:15 @@ -21,8 +32,8 @@ services: db: condition: service_healthy ports: - - "8069:8069" - - "8072:8072" + - "${ODOO_HTTP_PORT:-8069}:8069" + - "${ODOO_LONGPOLLING_PORT:-8072}:8072" environment: HOST: 0.0.0.0 PORT: "8069" @@ -30,7 +41,22 @@ services: - ./:/mnt/extra-addons/ - ./odoo.conf:/etc/odoo/odoo.conf:ro - odoo_data_addons_cm:/var/lib/odoo - command: odoo -c /etc/odoo/odoo.conf + # OCA sources living outside this repo (dependencies that are not + # here: `pos_payment_method_cashdro`, `account_banking_mandate`, ...), + # mounted read-only from $ODOO_SRC. + - ${ODOO_SRC:?set ODOO_SRC in .env, see .env.example}/account-invoice-reporting:/mnt/oca/account-invoice-reporting:ro + - ${ODOO_SRC}/account-invoicing:/mnt/oca/account-invoicing:ro + - ${ODOO_SRC}/bank-payment:/mnt/oca/bank-payment:ro + - ${ODOO_SRC}/community-data-files:/mnt/oca/community-data-files:ro + - ${ODOO_SRC}/l10n-spain:/mnt/oca/l10n-spain:ro + - ${ODOO_SRC}/pos:/mnt/oca/pos:ro + - ${ODOO_SRC}/product-attribute:/mnt/oca/product-attribute:ro + - ${ODOO_SRC}/purchase-workflow:/mnt/oca/purchase-workflow:ro + - ${ODOO_SRC}/sale-workflow:/mnt/oca/sale-workflow:ro + - ${ODOO_SRC}/stock-logistics-workflow:/mnt/oca/stock-logistics-workflow:ro + command: > + odoo -c /etc/odoo/odoo.conf + --addons-path=${ODOO_ADDONS_PATH:?set ODOO_ADDONS_PATH in .env, see .env.example} volumes: postgres_data_addons_cm: diff --git a/pos_payment_method_cashdro_fix/README.rst b/pos_payment_method_cashdro_fix/README.rst index 9854e0a..74ef554 100644 --- a/pos_payment_method_cashdro_fix/README.rst +++ b/pos_payment_method_cashdro_fix/README.rst @@ -57,8 +57,8 @@ To check the three fixes on a PoS with a CashDro terminal: configured host. The Python side is covered by the tests. The base module lives outside this -repo, so the OCA sources have to be on the addons path (see -``docker-compose.override.yml``, which is local and untracked):: +repo, so the OCA sources have to be on the addons path (mounted by +``docker-compose.yml`` from ``ODOO_SRC``, set in your local ``.env``):: docker-compose run --rm odoo odoo -c /etc/odoo/odoo.conf \ --addons-path=/mnt/extra-addons,/mnt/oca/pos,/usr/lib/python3/dist-packages/odoo/addons \ diff --git a/pos_payment_method_cashdro_fix/readme/USAGE.rst b/pos_payment_method_cashdro_fix/readme/USAGE.rst index 6499224..2b6d928 100644 --- a/pos_payment_method_cashdro_fix/readme/USAGE.rst +++ b/pos_payment_method_cashdro_fix/readme/USAGE.rst @@ -13,8 +13,8 @@ To check the three fixes on a PoS with a CashDro terminal: configured host. The Python side is covered by the tests. The base module lives outside this -repo, so the OCA sources have to be on the addons path (see -``docker-compose.override.yml``, which is local and untracked):: +repo, so the OCA sources have to be on the addons path (mounted by +``docker-compose.yml`` from ``ODOO_SRC``, set in your local ``.env``):: docker-compose run --rm odoo odoo -c /etc/odoo/odoo.conf \ --addons-path=/mnt/extra-addons,/mnt/oca/pos,/usr/lib/python3/dist-packages/odoo/addons \