[UPD] docker: support ERPLibre script, poetry and pyenv

- add script docker
This commit is contained in:
Mathieu Benoit 2020-08-02 00:10:34 -04:00
parent 789a26a432
commit a16224e948
12 changed files with 108 additions and 102 deletions

View file

@ -2,7 +2,6 @@ version: "3.3"
services:
ERPLibre:
image: technolibre/erplibre:12.0-pkg
# image: technolibre/erplibre:12.0-src
ports:
- 8069:8069
- 8071:8071
@ -12,19 +11,12 @@ services:
PASSWORD: mysecretpassword
USER: odoo
POSTGRES_DB: postgres
# CURRENT_UID: ${CURRENT_UID}
depends_on:
- db
# networks:
# - front
#entrypoint: odoo
#command: bash -c "sleep 1000 && odoo --without-demo=ALL -i base -d odoo "
command: odoo
# user:
volumes:
# - .:/ERPLibre
# See the volume section at the end of the file
- erplibre_data_dir:/var/lib/odoo
- erplibre_data_dir:/home/odoo/.local/share/Odoo/
db:
image: postgres:12.3
@ -35,18 +27,6 @@ services:
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- erplibre-db-data:/var/lib/postgresql/data/pgdata
#networks:
# - front
#networks:
# front:
#
# driver: bridge
# ipam:
# driver: default
# config:
# - subnet: 172.16.237.0/24
# We configure volume without specific destination to let docket manage it. To configure it through docker use (read related documentation before continuing) :
# - docker volume --help

View file

@ -6,6 +6,12 @@ SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
# Generate locale C.UTF-8 for postgres and general locale data
ENV LANG C.UTF-8
ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8" \
PATH="/opt/pyenv/shims:/opt/pyenv/bin:$PATH" \
PYENV_ROOT="/opt/pyenv" \
PYENV_SHELL="bash"
ENV ODOO_PREFIX /ERPLibre
ENV ODOO_EXEC_BIN $ODOO_PREFIX/odoo/odoo-bin
@ -36,49 +42,38 @@ RUN apt-get update \
python3-psycopg2 \
xz-utils \
git \
wget \
libxslt-dev \
libzip-dev \
libldap2-dev \
libsasl2-dev \
node-less \
gdebi-core \
libffi-dev \
iproute2 \
libmariadbd-dev \
inetutils-ping \
build-essential \
libsqlite3-dev \
sqlite3 \
bzip2 \
libbz2-dev \
zlib1g-dev \
libssl-dev \
openssl \
libgdbm-dev \
libgdbm-compat-dev \
liblzma-dev \
libreadline-dev \
libncursesw5-dev \
libffi-dev \
uuid-dev \
&& curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb \
&& echo '7e35a63f9db14f93ec7feeb0fce76b30c08f2057 wkhtmltox.deb' | sha1sum -c - \
&& apt-get install -y --no-install-recommends ./wkhtmltox.deb \
&& rm -rf /var/lib/apt/lists/* wkhtmltox.deb
# dpkg-deb -I odoo.deb | grep Depends: | sed "s/ /\\n/g" | egrep '^python\-*' | sed "s/,//g"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3-dateutil \
python3-decorator \
python3-docutils \
python3-feedparser \
python3-gevent \
python3-html2text \
python3-jinja2 \
python3-libsass \
python3-lxml \
python3-mako \
python3-mock \
python3-ofxparse \
python3-passlib \
python3-pil \
python3-psutil \
python3-psycopg2 \
python3-pydot \
python3-pyparsing \
python3-pypdf2 \
python3-reportlab \
python3-requests \
python3-serial \
python3-suds \
python3-tz \
python3-usb \
python3-vatnumber \
python3-werkzeug \
python3-xlsxwriter \
python3-chardet \
python3-xlrd \
&& rm -rf /var/lib/apt/lists/*
# install latest postgresql-client
# Install latest postgresql-client
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' > /etc/apt/sources.list.d/pgdg.list \
&& GNUPGHOME="$(mktemp -d)" \
&& export GNUPGHOME \
@ -88,13 +83,25 @@ RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' > /etc/
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& apt-get update \
&& apt-get install --no-install-recommends -y postgresql-client-12 \
&& apt-get install --no-install-recommends -y postgresql-client-12 libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/lib/postgresql/12/bin/pg_config /usr/bin/pg_config
# Install python with pyenv
# Reference https://github.com/bopen/docker-ubuntu-pyenv
COPY pyenv-version.txt python-versions.txt /
RUN git clone -b `cat /pyenv-version.txt` --single-branch --depth 1 https://github.com/pyenv/pyenv.git $PYENV_ROOT \
&& for version in `cat /python-versions.txt`; do pyenv install $version; done \
&& pyenv global `cat /python-versions.txt` \
&& find $PYENV_ROOT/versions -type d '(' -name '__pycache__' -o -name 'test' -o -name 'tests' ')' -exec rm -rf '{}' + \
&& find $PYENV_ROOT/versions -type f '(' -name '*.pyo' -o -name '*.exe' ')' -exec rm -f '{}' + \
&& rm -rf /tmp/* \
&& python --version \
&& python3 --version
# Install git-repo
RUN cd ; mkdir -p .bin/ && \
git config --global color.ui false && \
git config --global color.ui false && \
git config --global user.email "foo@bar.io" && \
git config --global user.name "Foo Bar" && \
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo && \
@ -103,11 +110,15 @@ RUN cd ; mkdir -p .bin/ && \
RUN groupadd --gid 101 --force odoo && \
useradd --non-unique --create-home --uid 101 --gid 101 odoo
# TODO delete poetry installation
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
# Copy entrypoint script and Odoo configuration file
COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
# # Set the default config file
# Set the default config file
ENV ODOO_RC /etc/odoo/odoo.conf
COPY ./odoo.conf $ODOO_RC
RUN chown odoo $ODOO_RC
@ -116,16 +127,12 @@ RUN mkdir $ODOO_PREFIX && \
chown odoo $ODOO_PREFIX && \
chmod 1777 $ODOO_PREFIX
# # Mount /var/lib/odoo to allow restoring filestore
# Mount /var/lib/odoo to allow restoring filestore
RUN chown odoo $ODOO_RC
# Expose Odoo services
EXPOSE 8069 8071 8072
COPY wait-for-psql.py /usr/local/bin/wait-for-psql.py
RUN chmod +X /usr/local/bin/wait-for-psql.py
RUN mkdir -p /var/lib/odoo && \
chown odoo /var/lib/odoo && \
chmod 1777 /var/lib/odoo

View file

@ -1,38 +1,43 @@
FROM technolibre/erplibre-base:12.0
ENV REPO_MANIFEST_URL http://git.erplibre.ca/ERPLibre
ENV BRANCH_ERPLIBRE dev/1.1.0
ARG WORKING_BRANCH
ENV BRANCH_ERPLIBRE $WORKING_BRANCH
RUN cat /etc/os-release
USER root
# Install Odoo
#ENV ODOO_VERSION 12.0
#ARG ODOO_RELEASE=20200417
#ARG ODOO_SHA=ca4a7485b0b75850ffe1458a8f3266839400a501
#RUN curl -o odoo.deb -sSL http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/odoo_${ODOO_VERSION}.${ODOO_RELEASE}_all.deb \
# && echo "${ODOO_SHA} odoo.deb" | sha1sum -c - \
# && apt-get update \
# && apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew install --no-install-recommends ./odoo.deb \
# && rm -rf /var/lib/apt/lists/* odoo.deb
RUN mkdir ~/.ssh/ && echo "StrictHostKeyChecking no" >> ~/.ssh/config && apt update && apt install ssh-client git -y --no-install-recommends && \
RUN mkdir ~/.ssh/ && \
echo "StrictHostKeyChecking no" >> ~/.ssh/config && \
apt update && \
apt install ssh-client git -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
RUN cd ; mkdir -p .bin/ && \
git config --global color.ui false && \
git config --global user.email "mathben@technolibre.ca" && \
git config --global user.name "Mathieu Benoit" && \
mkdir -p $ODOO_PREFIX && cd $ODOO_PREFIX && \
repo init -u $REPO_MANIFEST_URL -b $BRANCH_ERPLIBRE && \
repo sync -j 4 -c
git config --global user.email "foo@bar.io" && \
git config --global user.name "Foo Bar" && \
git clone $REPO_MANIFEST_URL -b $BRANCH_ERPLIBRE $ODOO_PREFIX
ADD repo_manifest_gen_org_prefix_path.py /root/.bin/
RUN chmod +x ~/.bin/repo_manifest_gen_org_prefix_path.py
RUN cd $ODOO_PREFIX && \
python -m venv .venv
RUN head /etc/odoo/odoo.conf && /root/.bin/repo_manifest_gen_org_prefix_path.py $ODOO_PREFIX/addons /etc/odoo/odoo.conf /etc/odoo/odoo.conf && head /etc/odoo/odoo.conf
RUN cd $ODOO_PREFIX && \
curl https://storage.googleapis.com/git-repo-downloads/repo > ./.venv/repo && \
chmod +x ./.venv/repo
RUN cd $ODOO_PREFIX && \
./script/update_manifest_dev.sh
RUN cd $ODOO_PREFIX && \
source /root/.poetry/env && \
poetry install
RUN cd $ODOO_PREFIX && \
head /etc/odoo/odoo.conf && \
./docker/repo_manifest_gen_org_prefix_path.py $ODOO_PREFIX/addons /etc/odoo/odoo.conf /etc/odoo/odoo.conf && \
head /etc/odoo/odoo.conf
user odoo

View file

@ -71,6 +71,8 @@ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRE
export
db_host = "host.docker.internal"
docker stats erplibre_ERPLibre_1
```
### Cleaning

View file

@ -70,13 +70,15 @@ case "$1" in
if [[ "$1" == "scaffold" ]] ; then
exec odoo "$@" || exec odoo-bin "$@"
else
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
exec $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}"
cd $ODOO_PREFIX
./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30
exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf
fi
;;
-*)
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
exec $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}"
cd $ODOO_PREFIX
./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30
exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf
;;
*)
exec "$@"

View file

@ -446,13 +446,13 @@ max_cron_threads = 1
# Prevents the worker from using more than <limit> CPU seconds for each
# request. If the limit is exceeded, the worker is killed
#-----------------------------------------------------------------------------
limit_time_cpu = 60
limit_time_cpu = 600
#-----------------------------------------------------------------------------
# Prevents the worker from taking longer than <limit> seconds to process a
# request. If the limit is exceeded, the worker is killed.
#-----------------------------------------------------------------------------
limit_time_real = 170
limit_time_real = 900
#-----------------------------------------------------------------------------
# Maximum allowed virtual memory per worker. If the limit is exceeded, the
@ -460,7 +460,7 @@ limit_time_real = 170
#
# (See chart above for recommended values)
#-----------------------------------------------------------------------------
limit_memory_soft = 255652815
; limit_memory_soft = 255652815
#-----------------------------------------------------------------------------
# Hard limit on virtual memory, any worker exceeding the limit will be
@ -471,7 +471,7 @@ limit_memory_soft = 255652815
# using PDF does not work. We are unsure why but this was the lowest amount
# for it to work.
#-----------------------------------------------------------------------------
limit_memory_hard = 1395864371
; limit_memory_hard = 1395864371
#-----------------------------------------------------------------------------
# Number of requests a worker will process before being recycled and restarted.
@ -482,13 +482,13 @@ limit_request = 8196
# Force a limit on the maximum number of records kept in the virtual osv_memory
# tables. The default is False, which means no count-based limit.
#-----------------------------------------------------------------------------
osv_memory_count_limit = False
; osv_memory_count_limit = False
#-----------------------------------------------------------------------------
# Force a limit on the maximum age of records kept in the virtual osv_memory
# tables. This is a decimal value expressed in hours, and the default is 1 hour.
#-----------------------------------------------------------------------------
osv_memory_age_limit = 1.0
; osv_memory_age_limit = 1.0
@ -520,4 +520,4 @@ osv_memory_age_limit = 1.0
# disable loading demo data for modules to be installed (comma-separated, use
# "all" for all modules). Default is none
#-----------------------------------------------------------------------------
without_demo = all
; without_demo = all

1
docker/pyenv-version.txt Normal file
View file

@ -0,0 +1 @@
v1.2.20

View file

@ -0,0 +1 @@
3.7.7

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!./.venv/bin/python
import argparse

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!./.venv/bin/python
import argparse
import psycopg2
import sys

View file

@ -1,6 +1,13 @@
#!/usr/bin/env bash
cd docker
docker build -f Dockerfile.base -t technolibre/erplibre-base:12.0 .
docker build -f Dockerfile.prod.pkg -t technolibre/erplibre:12.0-pkg .
ARGS=--build-arg=WORKING_BRANCH=$(git rev-parse --abbrev-ref HEAD)
set -e
# Build base
docker build ${ARGS} -f Dockerfile.base -t technolibre/erplibre-base:12.0 .
# Build prod
docker build ${ARGS} -f Dockerfile.prod.pkg -t technolibre/erplibre:12.0-pkg .
cd ..
docker-compose up -d

View file

@ -175,6 +175,7 @@ if [[ ! -d "${PYENV_PATH}" ]]; then
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
fi
echo -e "\n---- Export pyenv in ${PYENV_PATH} ----"
export PATH="${PYENV_PATH}/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"