This is a recipe for building a Docker container suitable for running automated unit tests on Odoo modules. The container is built using Fedora and the latest Odoo branch. Almost all dependencies are provided using official Fedora packages.
The resulting container is published on Docker Hub as
unipartdigital/odoo-tester:14.0
.
To build and publish the container image:
docker build -t unipartdigital/odoo-tester:14.0 .
docker push unipartdigital/odoo-tester:14.0
To run Odoo within the container:
docker run -it --rm unipartdigital/odoo-tester:14.0
Any extra arguments will be appended to the odoo-bin
command line.
For example, to install the product
module:
docker run -it --rm unipartdigital/odoo-tester:14.0 -i product
The primary use case for this container image is to allow for the
automated testing of external Odoo modules. An external module may
include a Dockerfile
such as:
FROM unipartdigital/odoo-tester:14.0
ADD addons/my_module /opt/odoo-addons/my_module
CMD ["--test-enable", "-i", "my_module"]
Tests can then be run (from within the external module's directory) using:
docker build -t my_module-tester .
docker run -it --rm my_module-tester
These commands can be invoked as part of a continuous integration system such as Travis CI, to ensure that the module's automated tests are run automatically for every commit and pull request.