In order to run odoo from the container we need to create and have accessible to the user the folder /var/lib/odoo.
Also, to use the shared folder with the host (NOTE: this is for local development purpose only, never ever do this on an exposed server) we need to create a user with the same uid as the host ones.
This is the Dockerfile to do that:
MAINTAINER Enrico La Cava “firstname.lastname@example.org”
RUN useradd -s /sbin/nologin -u 1000 odoo
RUN mkdir /var/lib/odoo
RUN chown odoo:odoo /var/lib/odoo
COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt
ENV PATH /usr/local/bin:/usr/bin:/bin:$PATH
CMD /bin/bash odoo.sh
The loading script odoo.sh is quite trivial:
python odoo.py –addons-path=addons -w odoo -r odoo –db_host odoo-db
We also need a postgreSQL instance running somewhere, the obviuous solution is to run another container and link them. So this is the new final running script:
#docker build -t “odoo_test:latest” /home/elacava/projects/odoo/devel/
docker run -d -p 5432 -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo –name odoo-db postgres
docker run -i –name odoo -v /home/elacava/projects/odoo/devel:/opt/odoo –link odoo-db:odoo-db odoo_test:latest
The build is not needed for normal running as we are using a shared volume for odoo files.
No tags for this post.