It might be a good idea to have an article about docker in general, what it is, why I choose to use it and how to install it on debian but the internet is full of that so, for now, next time.First install
I just want to say that the bash-completion for docker is VITAL, so download the file provided by docker and install the bash-completion package, if you already haven’t done it yet.
#apt-get install bash-completion
#cp docker /usr/share/bash-completion/completions
This will enable docker bash completion.
The instructions to install odoo are vague and incomplete, so I had to do a lot of tests and failed buildings. You just need to chroot in a fresh debootstrap environment with the odoo repository copied and start installing everything. Take extreme care of writing down all the packages you need and, when you are done, you have the list of dependencies and commands needed to fill in your building scripts.
Also, beware of pip, easy_install and apt-get! They fully hate each others. I opted for installing all the needed python modules with pip and using apt-get only for system libraries. This will enable me to update python dependencies without the need of checking if the debian package is ready or available.
Create an image from scratch can be tricky, I am using container because I want reproducibility so I have two scripts doing the heavy loading:
The first one creates a debootstrap environment in a temporary folder, it tweaks some configs (mostly apt) to reduce the space needed and speed up the building process. Then it starts a chroot environment and installs all the required packages with apt-get and the python requirements with pip.
The last part of the script creates a tar.xz archive of the environment and it builds the docker image with it. A few lines of cleanup et voilà!
You can find the first script mkimage.sh on GitHub.
The second script is dumb:
docker build -t "odoo_test:latest" /home/elacava/projects/odoo/devel/
docker run -it -v /home/elacava/projects/odoo/devel:/opt/odoo odoo_test:latest /bin/bash
It builds the docker image on top of the base one done before and run it. This is the Dockerfile:
MAINTAINER Enrico La Cava "email@example.com"
COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt
ENV PATH /usr/local/bin:/usr/bin:/bin:$PATH
I choose to run pip again in order to be able to change the requirements in the future, without the hassle to rebuild the base image (YES! Layering!).
The next step is to setup the image and the running script.