[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

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:
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: