FROM python:3.6-stretch
MAINTAINER Yaltik - Fabien Bourgeois <fabien@yaltik.com>

# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8

# Odoo dependencies from Debian APT repository
RUN apt-get update \
      && apt-get install -y --no-install-recommends \
        build-essential git mercurial curl \
        libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libjpeg-dev libpq-dev \
        libfreetype6-dev libssl1.0-dev \
        nodejs node-less xz-utils \
        postgresql-client-9.6

# Handle Node PATH
RUN ln -s /usr/bin/nodejs /usr/bin/node

# WKHTMLTOPDF and fonts
RUN curl -o wkhtmltox.tar.xz -SL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz \
      && echo '3f923f425d345940089e44c1466f6408b9619562 wkhtmltox.tar.xz' | sha1sum -c - \
      && tar xvf wkhtmltox.tar.xz \
      && cp wkhtmltox/lib/* /usr/local/lib/ \
      && cp wkhtmltox/bin/* /usr/local/bin/ \
      && cp -r wkhtmltox/share/man/man1 /usr/local/share/man/

# Packages cleanup
RUN apt-get purge -y --auto-remove \
      && apt-get clean \
      && rm -r ./wkhtmltox*

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

# Install OCB 11.0 latest
ENV ODOO_BRANCH 11.0
WORKDIR /opt/odoo
# Default user : odoo
USER odoo
RUN mkdir pipcache data backups extra-addons custom-addons
RUN git clone -b ${ODOO_BRANCH} --depth 1 https://github.com/OCA/OCB.git
RUN pip3 install --user -U pip
RUN pip3 install --user -r OCB/requirements.txt

# Launch scripts
COPY ./launch11.sh ./
COPY ./genconf.sh ./

# Post-install tasks
RUN touch odoo.conf

# Odoo default ports
EXPOSE 8069 8072

# Volumes : data dir for filestore and addons
VOLUME /opt/odoo/data

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