From bebc48d41cc5045bf245a6eacd55ffaa6e7da703 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 11 Jul 2018 22:23:19 +0200 Subject: [PATCH] initial commit --- README.md | 6 ++++ docker-compose.yml | 45 ++++++++++++++++++++++++++ odoo/Dockerfile | 17 ++++++++++ odoo/odoo.conf | 3 ++ posbox/Dockerfile | 66 ++++++++++++++++++++++++++++++++++++++ posbox/entrypoint.sh | 42 ++++++++++++++++++++++++ posbox/openerp-server.conf | 3 ++ 7 files changed, 182 insertions(+) create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 odoo/Dockerfile create mode 100644 odoo/odoo.conf create mode 100644 posbox/Dockerfile create mode 100755 posbox/entrypoint.sh create mode 100644 posbox/openerp-server.conf diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d0d53b --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Odoo PosBox in Docker + +Dockerfiles and Docker Compose configuration for running +Odoo PosBox in Docker. It additionally contains +[pos-addons](https://github.com/it-projects-llc/pos-addons) +for using receipt printers over the network. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bee7643 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: '2' +services: + web: + build: ./odoo + depends_on: + - db + ports: + - 8069:8069 + volumes: + - odoo-web-data:/var/lib/odoo + networks: + localnet: + ipv4_address: 10.5.0.2 + posbox: + build: ./posbox + command: -- --load=web,hw_proxy,hw_posbox_homepage,hw_escpos,hw_screen,hw_printer_network + ports: + - 8070:8069 + - 8072:8072 + volumes: + - /dev/bus/usb:/dev/bus/usb + networks: + localnet: + ipv4_address: 10.5.0.3 + db: + image: postgres:9.6 + environment: + - POSTGRES_PASSWORD=odoo + - POSTGRES_USER=odoo + - PGDATA=/var/lib/postgresql/data/pgdata + volumes: + - odoo-db-data:/var/lib/postgresql/data/pgdata + networks: + localnet: + ipv4_address: 10.5.0.4 +volumes: + odoo-web-data: + odoo-db-data: +networks: + localnet: + driver: bridge + ipam: + config: + - subnet: 10.5.0.0/16 + gateway: 10.5.0.1 diff --git a/odoo/Dockerfile b/odoo/Dockerfile new file mode 100644 index 0000000..654dc3b --- /dev/null +++ b/odoo/Dockerfile @@ -0,0 +1,17 @@ +FROM odoo:11 + +USER root + +RUN apt-get update \ + && apt-get -y install --no-install-recommends git \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /opt/posbox/addons \ + && chown -R odoo.odoo /opt/posbox + +USER odoo + +## Get pos-addons for pos_printer_network +RUN git clone --depth=1 -b 11.0 https://github.com/it-projects-llc/pos-addons.git \ + /opt/posbox/addons + +COPY odoo.conf /etc/odoo/odoo.conf diff --git a/odoo/odoo.conf b/odoo/odoo.conf new file mode 100644 index 0000000..d7a824a --- /dev/null +++ b/odoo/odoo.conf @@ -0,0 +1,3 @@ +[options] +addons_path = /mnt/extra-addons,/opt/posbox/addons +data_dir = /var/lib/odoo diff --git a/posbox/Dockerfile b/posbox/Dockerfile new file mode 100644 index 0000000..88ceef0 --- /dev/null +++ b/posbox/Dockerfile @@ -0,0 +1,66 @@ +FROM debian:jessie +MAINTAINER Odoo S.A. + +# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf +RUN set -x; \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + git \ + node-clean-css \ + node-less \ + python-gevent \ + python-netifaces \ + python-pip \ + python-pyinotify \ + python-renderpm \ + python-support \ + && curl -o wkhtmltox.deb -SL http://nightly.odoo.com/extra/wkhtmltox-0.12.1.2_linux-jessie-amd64.deb \ + && echo '40e8b906de658a2221b15e4e8cd82565a47d7ee8 wkhtmltox.deb' | sha1sum -c - \ + && dpkg --force-depends -i wkhtmltox.deb \ + && apt-get -y install -f --no-install-recommends \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false npm \ + && rm -rf /var/lib/apt/lists/* wkhtmltox.deb \ + && pip install psycogreen==1.0 + +# Install Odoo +ENV ODOO_VERSION 8.0 +ENV ODOO_RELEASE 20170815 +RUN set -x; \ + curl -o odoo.deb -SL http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/odoo_${ODOO_VERSION}.${ODOO_RELEASE}_all.deb \ + && echo '5835e966a07e5684b4f7bcc39585276b0bb68254 odoo.deb' | sha1sum -c - \ + && dpkg --force-depends -i odoo.deb \ + && apt-get update \ + && apt-get -y install -f --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* odoo.deb + +# Copy entrypoint script and Odoo configuration file +COPY ./entrypoint.sh / +COPY ./openerp-server.conf /etc/odoo/ +RUN chown odoo /etc/odoo/openerp-server.conf + +# Mount /var/lib/odoo to allow restoring filestore and /mnt/extra-addons for users addons +RUN mkdir -p /mnt/extra-addons \ + && chown -R odoo /mnt/extra-addons +VOLUME ["/var/lib/odoo", "/mnt/extra-addons"] + +# Expose Odoo services +EXPOSE 8069 8071 + +# Set the default config file +ENV OPENERP_SERVER /etc/odoo/openerp-server.conf + +## Prepare for pos-addons / hw_printer_network +RUN pip install -U pip setuptools \ + && pip install python-escpos + +# hw_printer_network is located in 11.0 branch, but works with earler versions too +RUN git clone --depth=1 -b 11.0 https://github.com/it-projects-llc/pos-addons.git \ + /opt/posbox/addons + +# Set default user when running the container +USER odoo + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["openerp-server"] diff --git a/posbox/entrypoint.sh b/posbox/entrypoint.sh new file mode 100755 index 0000000..a958c3c --- /dev/null +++ b/posbox/entrypoint.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +# set the postgres database host, port, user and password according to the environment +# and pass them as arguments to the odoo process if not present in the config file +: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}} +: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}} + +DB_ARGS=() +function check_config() { + param="$1" + value="$2" + if ! grep -q -E "^\s*\b${param}\b\s*=" "$OPENERP_SERVER" ; then + DB_ARGS+=("--${param}") + DB_ARGS+=("${value}") + fi; +} +check_config "db_host" "$HOST" +check_config "db_port" "$PORT" +check_config "db_user" "$USER" +check_config "db_password" "$PASSWORD" + +case "$1" in + -- | openerp-server) + shift + if [[ "$1" == "scaffold" ]] ; then + exec openerp-server "$@" + else + exec openerp-server "$@" "${DB_ARGS[@]}" + fi + ;; + -*) + exec openerp-server "$@" "${DB_ARGS[@]}" + ;; + *) + exec "$@" +esac + +exit 1 diff --git a/posbox/openerp-server.conf b/posbox/openerp-server.conf new file mode 100644 index 0000000..2dc302d --- /dev/null +++ b/posbox/openerp-server.conf @@ -0,0 +1,3 @@ +[options] +addons_path = /opt/posbox/addons +data_dir = /var/lib/odoo