[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 <noreply@anthropic.com>
This commit is contained in:
GitHub Copilot 2026-08-17 13:57:25 +02:00
parent b3999e2283
commit 3eb79e2431
4 changed files with 55 additions and 7 deletions

22
.env.example Normal file
View file

@ -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/<repo>.
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

View file

@ -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 <addon> --test-enable --stop-after-init
services: services:
db: db:
image: postgres:15 image: postgres:15
@ -21,8 +32,8 @@ services:
db: db:
condition: service_healthy condition: service_healthy
ports: ports:
- "8069:8069" - "${ODOO_HTTP_PORT:-8069}:8069"
- "8072:8072" - "${ODOO_LONGPOLLING_PORT:-8072}:8072"
environment: environment:
HOST: 0.0.0.0 HOST: 0.0.0.0
PORT: "8069" PORT: "8069"
@ -30,7 +41,22 @@ services:
- ./:/mnt/extra-addons/ - ./:/mnt/extra-addons/
- ./odoo.conf:/etc/odoo/odoo.conf:ro - ./odoo.conf:/etc/odoo/odoo.conf:ro
- odoo_data_addons_cm:/var/lib/odoo - 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: volumes:
postgres_data_addons_cm: postgres_data_addons_cm:

View file

@ -57,8 +57,8 @@ To check the three fixes on a PoS with a CashDro terminal:
configured host. configured host.
The Python side is covered by the tests. The base module lives outside this 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 repo, so the OCA sources have to be on the addons path (mounted by
``docker-compose.override.yml``, which is local and untracked):: ``docker-compose.yml`` from ``ODOO_SRC``, set in your local ``.env``)::
docker-compose run --rm odoo odoo -c /etc/odoo/odoo.conf \ 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 \ --addons-path=/mnt/extra-addons,/mnt/oca/pos,/usr/lib/python3/dist-packages/odoo/addons \

View file

@ -13,8 +13,8 @@ To check the three fixes on a PoS with a CashDro terminal:
configured host. configured host.
The Python side is covered by the tests. The base module lives outside this 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 repo, so the OCA sources have to be on the addons path (mounted by
``docker-compose.override.yml``, which is local and untracked):: ``docker-compose.yml`` from ``ODOO_SRC``, set in your local ``.env``)::
docker-compose run --rm odoo odoo -c /etc/odoo/odoo.conf \ 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 \ --addons-path=/mnt/extra-addons,/mnt/oca/pos,/usr/lib/python3/dist-packages/odoo/addons \