FROM oraclelinux:6
LABEL maintainer="Yaltik - Fabien Bourgeois <fabien@yaltik.com>"

# OpenERP dependencies from CentOS
RUN yum update -y && \
      yum install -y python-devel pychart python-dateutil python-reportlab \
      python-lxml python-psycopg2 python-mako python-setuptools pytz PyYAML graphviz \
      python-imaging wget git unzip gcc && yum clean all

# Install OpenERP dependencies not available from CentOS6 repo
RUN wget -q https://files.pythonhosted.org/packages/6f/2c/47457771c02a8ff0f302b695e094ec309e30452232bd79198ee94fda689f/pyparsing-1.5.7.tar.gz && \
      easy_install pyparsing-1.5.7.tar.gz && \
      wget -q https://files.pythonhosted.org/packages/8d/ca/bed32e7ced110aeef48a223610e57382bc52a043e14de656de98a492546c/pydot-1.0.29.tar.gz && \
      easy_install pydot-1.0.29.tar.gz && \
      wget -q https://files.pythonhosted.org/packages/e1/d3/26a9d0fcdde02ebc35e600e6de6f3a8814423c056e2bde1be1f66f121bc4/vobject-0.8.2.tar.gz && \
      easy_install vobject-0.8.2.tar.gz && \
      wget -q https://files.pythonhosted.org/packages/9a/42/5040f056007156804229424674f7538fb40fbb3cc899c674c51c1f8830ac/PyWebDAV-0.9.4.tar.gz && \
      easy_install PyWebDAV-0.9.4.tar.gz
# Alternative : home install PyWebDAV, not useless finally
# RUN wget https://files.pythonhosted.org/packages/e9/14/5f2a654233e533797f32dd670dab8dd61ac974d5105950481e872bddb898/PyWebDAV-0.9.8.tar.gz
# RUN tar xzf PyWebDAV-0.9.8.tar.gz
# WORKDIR /PyWebDAV-0.9.8
# RUN python setup.py develop

# Create odoo user
RUN useradd odoo -md /opt/odoo

ENV ODOO_BRANCH 6.0
WORKDIR /opt/odoo
# Default user : odoo
USER odoo

# Install Odoo v6.0
RUN mkdir -p pipcache data backups extra-addons custom-addons www/html/ && \
      wget -q https://github.com/odoo/odoo/archive/${ODOO_BRANCH}.zip && \
      unzip ${ODOO_BRANCH}.zip && rm ${ODOO_BRANCH}.zip && \
      mv odoo-${ODOO_BRANCH} odoo
# RUN git clone -b ${ODOO_BRANCH} --depth 1 https://github.com/odoo/odoo.git
USER root
WORKDIR /opt/odoo/odoo/
RUN python setup.py install

# OpenERP 6 extra addons was used, so install it... and its dependencies
WORKDIR /opt/odoo/
RUN wget -q https://files.pythonhosted.org/packages/62/3a/81325e34bcc78f67cc33dfac64f44e7c8329d4481dec1b789267b98644c3/bzr-2.7.0.tar.gz && \
      easy_install bzr-2.7.0.tar.gz && \
      bzr init-repo extra-addons && \
      bzr branch lp:openobject-addons/extra-6.0 extra-addons/openerp-extra-6.0
# COPY openerp-extra-60.zip ./
# RUN unzip openerp-extra-60.zip && rm openerp-extra-60.zip
RUN wget -q https://files.pythonhosted.org/packages/66/e6/e0709aedeb4a5c92a1aeb8c47ab50e9506eafc865806801bd3f01d72b671/egenix-mx-base-3.2.9.zip && \
      easy_install egenix-mx-base-3.2.9.zip

# Prepare launch
USER odoo
COPY genconf60.sh genconf.sh
COPY launch60.sh launch.sh

EXPOSE 8069 8070 8071

CMD ["bash", "launch.sh"]
