Some tips when I take time to write them down.

Part 3 - Build a docker image

In this post, we'll create a custom docker image of odoo that fits our need.

Create a Docker file to the root folder of your addon/repo:

$ cd ~/odoo-docker/addons/my_awesome_addon
$ touch Dockerfile

Copy these lines into the file:

FROM odoo:latest

USER root
RUN apt update && apt install -y --no-install-recommends git

COPY ./ /tmp/
RUN python install

USER odoo

First, we tell docker that our image is based on the latest from odoo. Then, as root user, we install git to be able to install python dependencies from pip with git.

Finally, we copy our addon into the image and install it in python environment, then get back to odoo user.

Now, we can build the image and run the container:

$ docker build -t odoo-my-awesome-addon:10 .
$ docker run -p 8069:8069 --name my-container --link db-docker:db odoo-my-awesome-addon:10 -d new_database -i my_awesome_addon

You can access odoo with the web interface. Select the right database, check that your addon is installed.

Once done, imagine that our addon depends of an OCA addon, for example partner_firstname of partner-contact repo.

Adding the dependency to partner_contact in the manifest makes it only really required when odoo is launched. To make it required at our module installation we need to update our and adding a requirement file for pip. (not sure why I can't use setuptools)

Add required depencies to

import setuptools

        'depends_override': {
            'partner_firstname': 'odoo10-addon-partner-firstname',
        ''  # Not working for some reason..

And to be able to install it with pip, add the project a requirements.txt with this content:



Now you can install your addon with pip:

$ pip install -r requirements.txt -e . (equivalent to python develop)
$ pip install -r requirements.txt . (equivalent to python install)

Edit the Dockerfile to use the new command to install the addon. Rebuild the image and run the container. Check that your addon and partner_firstname are installed.

Think to save the changes:

$ git add --all
$ git commit -m "Allow creation of a custom docker image of odoo"
$ git push