From dcb21101694e5a3d2d42b3c2da0ab657543b8b2a Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Tue, 6 Nov 2018 17:32:00 +0100 Subject: [PATCH] [ADD]Flectra base and dev images --- odoo/base.yml | 18 +++++++++++ odoo/dev.yml | 21 +++++++++++++ odoo/flectra/Dockerfile | 60 +++++++++++++++++++++++++++++++++++++ odoo/flectra/Dockerfile.dev | 12 ++++++++ odoo/flectra/genconf.sh | 45 ++++++++++++++++++++++++++++ odoo/flectra/i18n.sh | 4 +++ odoo/flectra/launch.dev.sh | 15 ++++++++++ odoo/flectra/launch.sh | 7 +++++ odoo/flectra/pgcli.sh | 3 ++ odoo/flectra/shell.sh | 3 ++ 10 files changed, 188 insertions(+) create mode 100644 odoo/flectra/Dockerfile create mode 100644 odoo/flectra/Dockerfile.dev create mode 100644 odoo/flectra/genconf.sh create mode 100644 odoo/flectra/i18n.sh create mode 100644 odoo/flectra/launch.dev.sh create mode 100644 odoo/flectra/launch.sh create mode 100644 odoo/flectra/pgcli.sh create mode 100644 odoo/flectra/shell.sh diff --git a/odoo/base.yml b/odoo/base.yml index fa72ce4..8b833de 100644 --- a/odoo/base.yml +++ b/odoo/base.yml @@ -120,6 +120,24 @@ services: POSTGRES_USER: odoo POSTGRES_PASSWORD: somethingToChange + flectra: + init: true + build: + context: ./flectra + dockerfile: Dockerfile + image: registry.yaltik.net/flectra:yaltik1 + environment: + DB_MAXCONN: 20 + XMLRPC_PORT: 8069 + LONGPOLLING_PORT: 8072 + WORKERS: 2 + LIMIT_TIME_CPU: 720 + LIMIT_TIME_REAL: 1440 + ADMIN_PASSWORD: somethingToChange + LIST_DB: "False" + POSTGRES_USER: flectra + POSTGRES_PASSWORD: somethingToChange + odoocmd: build: context: ./scripts diff --git a/odoo/dev.yml b/odoo/dev.yml index cb08b4d..d63fe6a 100644 --- a/odoo/dev.yml +++ b/odoo/dev.yml @@ -88,3 +88,24 @@ services: LIST_DB: "True" POSTGRES_USER: odoo POSTGRES_PASSWORD: somethingToChange + + flectradev: + extends: + file: base.yml + service: flectra + build: + context: ./flectra + dockerfile: Dockerfile.dev + image: registry.yaltik.net/flectradev:yaltik1 + environment: + DEV: 1 + CODE_FOLDER: code + ADMIN_PASSWORD: dev + LIST_DB: "True" + DB_MAXCONN: 20 + WORKERS: 2 + LIMIT_TIME_CPU: 3000 + LIMIT_TIME_REAL: 6000 + LIMIT_MEMORY_SOFT: 7000000000 + LIMIT_MEMORY_HARD: 16000000000 + diff --git a/odoo/flectra/Dockerfile b/odoo/flectra/Dockerfile new file mode 100644 index 0000000..057a32b --- /dev/null +++ b/odoo/flectra/Dockerfile @@ -0,0 +1,60 @@ +FROM debian:stretch +MAINTAINER Yaltik - Fabien Bourgeois + +# 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 + +# Flectra 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 \ + python3-dev python3-setuptools python3-pip \ + 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 flectra user +RUN useradd flectra -md /opt/flectra + +# Install Flectra 1.0 latest +ENV FLECTRA_BRANCH 1.0 +WORKDIR /opt/flectra +# Default user +USER flectra +RUN mkdir pipcache data backups extra-addons custom-addons +RUN git clone -b ${FLECTRA_BRANCH} --depth 1 https://gitlab.com/flectra-hq/flectra +RUN pip3 install --user -U pip +RUN .local/bin/pip3 install --user -r flectra/requirements.txt + +# Launch scripts +COPY ./launch.sh ./ +COPY ./genconf.sh ./ + +# Post-install tasks +RUN touch flectra.conf + +# Flectra default ports +EXPOSE 7072 7073 + +# Volumes : data dir for filestore and addons +VOLUME /opt/flectra/data + +CMD [ "bash", "launch.sh" ] diff --git a/odoo/flectra/Dockerfile.dev b/odoo/flectra/Dockerfile.dev new file mode 100644 index 0000000..647068f --- /dev/null +++ b/odoo/flectra/Dockerfile.dev @@ -0,0 +1,12 @@ +FROM registry.yaltik.net/flectra:yaltik1 +MAINTAINER Yaltik - Fabien Bourgeois + +# PostgreSQL CLI +RUN .local/bin/pip3 install --user pgcli +COPY pgcli.sh ./ +# Flectra specific +RUN .local/bin/pip3 install --user watchdog +COPY shell.sh ./ +COPY i18n.sh ./ +COPY launch.dev.sh ./launch.sh +ENV DEV 1 diff --git a/odoo/flectra/genconf.sh b/odoo/flectra/genconf.sh new file mode 100644 index 0000000..3714dd1 --- /dev/null +++ b/odoo/flectra/genconf.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Small program, inspired from Yajo's one : https://bitbucket.org/yajo/docker-odoo +# It generates configuration file + +CONF=/opt/flectra/flectra.conf +ADDONS_PATH="/opt/flectra/flectra/addons,/opt/flectra/data/addons" + +cd extra-addons +for d in */ ; do + if ! [ "$d" == "*/" ]; then + ADDONS_PATH="$ADDONS_PATH,/opt/flectra/extra-addons/$d" + fi +done + +cd ../custom-addons +for d in */ ; do + if ! [ "$d" == "*/" ]; then + ADDONS_PATH="$ADDONS_PATH,/opt/flectra/custom-addons/$d" + fi +done + +# Configuration generation +echo " +[options] +; Configuration file auto-generated +addons_path = $ADDONS_PATH +data_dir = ${DATA:=/opt/flectra/data} +dbfilter = ${DB_FILTER} +db_name = ${DB_NAME} +db_host = ${DB_HOST:=postgres} +db_port = ${DB_PORT:=5432} +db_user = $POSTGRES_USER +db_password = $POSTGRES_PASSWORD +db_maxconn = ${DB_MAXCONN:=10} +list_db = ${LIST_DB:=True} +xmlrpc_port = ${XMLRPC_PORT:=8069} +longpolling_port = ${LONGPOLLING_PORT:=8072} +proxy_mode = ${PROXY_MODE:=True} +workers = ${WORKERS:=1} +limit_time_cpu = ${LIMIT_TIME_CPU:=60} +limit_time_real = ${LIMIT_TIME_REAL:=120} +limit_memory_soft = ${LIMIT_MEMORY_SOFT:=671088640} +limit_memory_hard = ${LIMIT_MEMORY_HARD:=1610612736} +admin_passwd = ${ADMIN_PASSWORD:=admin}" > $CONF diff --git a/odoo/flectra/i18n.sh b/odoo/flectra/i18n.sh new file mode 100644 index 0000000..2698856 --- /dev/null +++ b/odoo/flectra/i18n.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd "custom-addons/$CODE_FOLDER/$2/i18n/" && /opt/flectra/flectra/flectra-bin -c /opt/flectra/flectra.conf -d "$1" --i18n-export="$2".po --modules="$2" && mv "$2".po "$2".pot && cd /opt/flectra +cd "custom-addons/$CODE_FOLDER/$2/i18n/" && /opt/flectra/flectra/flectra-bin -c /opt/flectra/flectra.conf -d "$1" --i18n-export=fr.po --modules="$2" --language=fr_FR && cd /opt/flectra diff --git a/odoo/flectra/launch.dev.sh b/odoo/flectra/launch.dev.sh new file mode 100644 index 0000000..f87aa35 --- /dev/null +++ b/odoo/flectra/launch.dev.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +CONF=/opt/flectra/flectra.conf +FLECTRACMD="/opt/flectra/flectra/flectra-bin --config $CONF" + +if [ $LOAD ]; then + FLECTRACMD="$FLECTRACMD --load=$LOAD" +fi + +if [ "$DEV" == 1 ]; then + FLECTRACMD="$FLECTRACMD --dev all --log-handler :DEBUG" +fi + +# Configuration generation and Flectra launch +bash genconf.sh && $FLECTRACMD diff --git a/odoo/flectra/launch.sh b/odoo/flectra/launch.sh new file mode 100644 index 0000000..13e852f --- /dev/null +++ b/odoo/flectra/launch.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +CONF=/opt/flectra/flectra.conf +FLECTRACMD="/opt/flectra/flectra/flectra-bin --config $CONF" + +# Configuration generation and Flectra launch +bash genconf.sh && $FLECTRACMD diff --git a/odoo/flectra/pgcli.sh b/odoo/flectra/pgcli.sh new file mode 100644 index 0000000..1799bbd --- /dev/null +++ b/odoo/flectra/pgcli.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./.local/bin/pgcli postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@${DB_HOST:=postgres} diff --git a/odoo/flectra/shell.sh b/odoo/flectra/shell.sh new file mode 100644 index 0000000..5484920 --- /dev/null +++ b/odoo/flectra/shell.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/opt/flectra/flectra/flectra-bin shell -c flectra.conf -d "$@" --no-xmlrpc