diff --git a/docker-compose.yml b/docker-compose.yml index 44203f5..cc2a6e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,9 @@ services: PASSWORD: mysecretpassword USER: odoo POSTGRES_DB: postgres + STOP_BEFORE_INIT: "False" + DB_NAME: "" + UPDATE_ALL_DB: "False" depends_on: - db command: odoo diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index 2a0b0d3..3f992b8 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -85,7 +85,7 @@ RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' > /etc/ && rm -rf /var/lib/apt/lists/* # Install npm dependencies -RUN sudo npm install -g rtlcss less \ +RUN npm install -g rtlcss less \ && ln -fs /usr/local/bin/lessc /usr/bin/lessc # Install python with pyenv @@ -114,7 +114,7 @@ RUN groupadd --gid 101 --force odoo && \ # TODO delete poetry installation # Install Poetry -RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python +RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - -y --preview --version 1.0.10 #curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py # Copy entrypoint script and Odoo configuration file diff --git a/docker/Dockerfile.prod.pkg b/docker/Dockerfile.prod.pkg index 78820ca..4334e1d 100644 --- a/docker/Dockerfile.prod.pkg +++ b/docker/Dockerfile.prod.pkg @@ -2,7 +2,9 @@ FROM technolibre/erplibre-base:1.1.0 ENV REPO_MANIFEST_URL http://git.erplibre.ca/ERPLibre ARG WORKING_BRANCH +ARG WORKING_HASH ENV BRANCH_ERPLIBRE $WORKING_BRANCH +ENV COMMIT_ERPLIBRE $WORKING_HASH RUN cat /etc/os-release @@ -12,13 +14,15 @@ 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/* + rm -rf /var/lib/apt/lists/* RUN cd ; mkdir -p .bin/ && \ git config --global color.ui false && \ - 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 + git config --global user.email "foo@bar.io" && \ + git config --global user.name "Foo Bar" && \ + if [ "$BRANCH_ERPLIBRE" = "HEAD" ]; then git clone $REPO_MANIFEST_URL $ODOO_PREFIX ; else git clone $REPO_MANIFEST_URL -b $BRANCH_ERPLIBRE $ODOO_PREFIX; fi && \ + cd $ODOO_PREFIX && \ + git checkout $COMMIT_ERPLIBRE RUN cd $ODOO_PREFIX && \ python -m venv .venv diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index bf1137f..3ed326c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -71,14 +71,29 @@ case "$1" in exec odoo "$@" || exec odoo-bin "$@" else cd $ODOO_PREFIX + if [[ "${STOP_BEFORE_INIT}" == "True" ]] ; then + sleep 999999 + fi ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + if [[ "${UPDATE_ALL_DB}" == "True" ]] ; then + # --stop-after-init + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" + else + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + fi fi ;; -*) cd $ODOO_PREFIX + if [[ "${STOP_BEFORE_INIT}" == "True" ]] ; then + sleep 999999 + fi ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + if [[ "${UPDATE_ALL_DB}" == "True" ]] ; then + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" + else + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + fi ;; *) exec "$@" diff --git a/docker/odoo.conf b/docker/odoo.conf index b9b9c4e..1a2c04e 100644 --- a/docker/odoo.conf +++ b/docker/odoo.conf @@ -446,13 +446,13 @@ max_cron_threads = 1 # Prevents the worker from using more than CPU seconds for each # request. If the limit is exceeded, the worker is killed #----------------------------------------------------------------------------- -limit_time_cpu = 600 +limit_time_cpu = 2400 #----------------------------------------------------------------------------- # Prevents the worker from taking longer than seconds to process a # request. If the limit is exceeded, the worker is killed. #----------------------------------------------------------------------------- -limit_time_real = 900 +limit_time_real = 3600 #----------------------------------------------------------------------------- # Maximum allowed virtual memory per worker. If the limit is exceeded, the diff --git a/script/docker_build.sh b/script/docker_build.sh index 3a99a79..cf2bc7e 100755 --- a/script/docker_build.sh +++ b/script/docker_build.sh @@ -1,15 +1,22 @@ #!/usr/bin/env bash . ./env_var.sh +ARGS="" + +for arg in "$@" +do + if [ "$arg" == "--no-cache" ] + then + ARGS="${ARGS} --no-cache" + fi +done + # Rewrite docker-compose ./script/docker_update_version.py --version=${ERPLIBRE_VERSION} --base=${ERPLIBRE_DOCKER_BASE} --prod=${ERPLIBRE_DOCKER_PROD} cd docker -ARGS=--build-arg=WORKING_BRANCH=$(git rev-parse --abbrev-ref HEAD) - -# Clear cache -# ARGS="${ARGS} --no-cache" +ARGS="${ARGS} --build-arg=WORKING_BRANCH=$(git rev-parse --abbrev-ref HEAD) --build-arg=WORKING_HASH=$(git rev-parse --verify HEAD)" set -e diff --git a/script/install_locally.sh b/script/install_locally.sh index 9d16bc6..c3646f4 100755 --- a/script/install_locally.sh +++ b/script/install_locally.sh @@ -179,6 +179,7 @@ PYTHON_EXEC=${PYENV_VERSION_PATH}/bin/python POETRY_PATH=~/.poetry VENV_PATH=./.venv VENV_REPO_PATH=${VENV_PATH}/repo +POETRY_VERSION=1.0.10 if [[ ! -d "${PYENV_PATH}" ]]; then echo -e "\n---- Installing pyenv in ${PYENV_PATH} ----" @@ -198,10 +199,11 @@ fi pyenv local 3.7.7 if [[ ! -d "${POETRY_PATH}" ]]; then + # Delete directory ~/.poetry and .venv to force update to new version echo -e "\n---- Installing poetry for reliable python package ----" # curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | ${PYTHON_EXEC} curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py - python get-poetry.py -y --preview + python get-poetry.py -y --preview --version ${POETRY_VERSION} fi if [[ ! -d ${VENV_PATH} ]]; then diff --git a/script/update_manifest_dev.sh b/script/update_manifest_dev.sh index 0ad02ac..12d75a4 100755 --- a/script/update_manifest_dev.sh +++ b/script/update_manifest_dev.sh @@ -6,6 +6,6 @@ #EL_MANIFEST_DEV="./manifest/default.dev.xml" # Update git-repo -./.venv/repo init -u http://git.erplibre.ca/ERPLibre -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_DEV} +./.venv/repo init -u http://git.erplibre.ca/ERPLibre -b $(git rev-parse --verify HEAD) -m ${EL_MANIFEST_DEV} #./.venv/repo sync --force-sync ./.venv/repo sync --force-sync -v diff --git a/script/update_manifest_local_dev.sh b/script/update_manifest_local_dev.sh index f33661b..b9ccb75 100755 --- a/script/update_manifest_local_dev.sh +++ b/script/update_manifest_local_dev.sh @@ -9,7 +9,7 @@ git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & DAEMON_PID=$! -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_DEV} +./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${EL_MANIFEST_DEV} ./.venv/repo sync -v --force-sync -m ${EL_MANIFEST_DEV} kill ${DAEMON_PID} diff --git a/script/update_manifest_local_experimental.sh b/script/update_manifest_local_experimental.sh index 7a8c71a..b96121f 100755 --- a/script/update_manifest_local_experimental.sh +++ b/script/update_manifest_local_experimental.sh @@ -10,7 +10,7 @@ git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & DAEMON_PID=$! -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_EXP} +./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${EL_MANIFEST_EXP} ./.venv/repo sync -v --force-sync -m ${EL_MANIFEST_EXP} kill ${DAEMON_PID} diff --git a/script/update_manifest_local_prod.sh b/script/update_manifest_local_prod.sh index 4d26aa3..501ef68 100755 --- a/script/update_manifest_local_prod.sh +++ b/script/update_manifest_local_prod.sh @@ -9,7 +9,7 @@ git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & DAEMON_PID=$! -./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_PROD} +./.venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${EL_MANIFEST_PROD} ./.venv/repo sync -v -m ${EL_MANIFEST_PROD} kill ${DAEMON_PID} diff --git a/script/update_manifest_prod.sh b/script/update_manifest_prod.sh index 70a701e..b9f5ba0 100755 --- a/script/update_manifest_prod.sh +++ b/script/update_manifest_prod.sh @@ -6,6 +6,6 @@ #EL_MANIFEST_DEV="./manifest/default.dev.xml" # Update git-repo -./.venv/repo init -u http://git.erplibre.ca/ERPLibre -b $(git rev-parse --abbrev-ref HEAD) +./.venv/repo init -u http://git.erplibre.ca/ERPLibre -b $(git rev-parse --verify HEAD) #./.venv/repo sync --force-sync ./.venv/repo sync -v