From 1b44cd697e74546d9fa9c34a30a4fe16e7b221ca Mon Sep 17 00:00:00 2001 From: Don Kendall Date: Sat, 18 Jun 2022 21:19:42 -0400 Subject: [PATCH] imp: su-exec from gosu (for amd64 on arm emulation) --- 14.0/Dockerfile | 22 ++++++++++++++++++++-- 15.0/Dockerfile | 34 +++++++++++++++++++++++++++++++++- bin/docker-entrypoint.sh | 6 +++--- bin/runmigration | 2 +- bin/runtests | 6 +++--- bin/testdb-gen | 2 +- bin/testdb-update | 2 +- 7 files changed, 62 insertions(+), 12 deletions(-) diff --git a/14.0/Dockerfile b/14.0/Dockerfile index d162163f..1105bdd1 100644 --- a/14.0/Dockerfile +++ b/14.0/Dockerfile @@ -41,9 +41,27 @@ RUN set -x; \ && pip install -r /odoo/base_requirements.txt --ignore-installed \ && /install/purge_dev_package_and_cache.sh -# grab gosu for easy step-down from root and dockerize to generate template and +ARG OS=buster +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ ${OS}-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ + && curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ + && curl -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c; \ + \ + fetch_deps='gcc libc-dev'; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + $fetch_deps \ + postgresql-client-14 \ + && apt-get clean all \ + && rm -rf /var/lib/apt/lists/* \ + gcc -Wall \ + /usr/local/bin/su-exec.c -o/usr/local/bin/su-exec; \ + chown root:root /usr/local/bin/su-exec; \ + chmod 0755 /usr/local/bin/su-exec; \ + rm /usr/local/bin/su-exec.c; + +# dockerize to generate template # and gosu for easy step-down from root and /install/gosu.sh && # wait on postgres -RUN /install/gosu.sh && /install/dockerize.sh +RUN /install/dockerize.sh COPY ./src_requirements.txt /odoo COPY ./bin /odoo-bin diff --git a/15.0/Dockerfile b/15.0/Dockerfile index c71623f5..e306bed3 100644 --- a/15.0/Dockerfile +++ b/15.0/Dockerfile @@ -38,13 +38,45 @@ RUN set -x; \ && /install/kwkhtml_client.sh \ && /install/kwkhtml_client_force_python3.sh \ && /install/dev_package.sh \ + && python3 -m pip install --force-reinstall pip setuptools \ + && pip install -r /odoo/base_requirements.txt --ignore-installed \ + && pip install debugpy pylint inotify + # \ + # && /install/purge_dev_package_and_cache.sh + +# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf +RUN set -x; \ + sh -c /install/package_odoo_13.0_14.0.sh \ + && /install/setup-pip.sh \ + && /install/postgres.sh \ + && /install/kwkhtml_client.sh \ + && /install/kwkhtml_client_force_python3.sh \ + && /install/dev_package.sh \ && python3 -m pip install --force-reinstall pip "setuptools<58" \ && pip install -r /odoo/base_requirements.txt --ignore-installed \ && /install/purge_dev_package_and_cache.sh +ARG OS=bullseye +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ ${OS}-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ + && curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ + && curl -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c; \ + \ + fetch_deps='gcc libc-dev'; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + $fetch_deps \ + postgresql-client-14 \ + && apt-get clean all \ + && rm -rf /var/lib/apt/lists/* \ + gcc -Wall \ + /usr/local/bin/su-exec.c -o/usr/local/bin/su-exec; \ + chown root:root /usr/local/bin/su-exec; \ + chmod 0755 /usr/local/bin/su-exec; \ + rm /usr/local/bin/su-exec.c; + # grab gosu for easy step-down from root and dockerize to generate template and # wait on postgres -RUN /install/gosu.sh && /install/dockerize.sh +RUN /install/dockerize.sh COPY ./src_requirements.txt /odoo COPY ./bin /odoo-bin diff --git a/bin/docker-entrypoint.sh b/bin/docker-entrypoint.sh index 3b761a5d..d4c6287f 100755 --- a/bin/docker-entrypoint.sh +++ b/bin/docker-entrypoint.sh @@ -17,7 +17,7 @@ export PGAPPNAME=${HOSTNAME} # As docker-compose exec do not launch the entrypoint # init PG variable into .bashrc so it will be initialized -# when doing docker-compose exec odoo gosu odoo bash +# when doing docker-compose exec odoo su-exec odoo bash touch /home/odoo/.bashrc chown odoo:odoo /home/odoo/.bashrc echo " @@ -146,7 +146,7 @@ if [ "$BASE_CMD" = "odoo" ] || [ "$BASE_CMD" = "odoo.py" ] ; then if [[ ! " ${ARGS[@]} " =~ " --help " ]] && [[ ! " ${ARGS[@]:0:1} " =~ " shell " ]]; then if [ -z "$MIGRATE" -o "$MIGRATE" = True ]; then - gosu odoo migrate + su-exec odoo migrate fi fi @@ -156,7 +156,7 @@ if [ "$BASE_CMD" = "odoo" ] || [ "$BASE_CMD" = "odoo.py" ] ; then run-parts --verbose "$START_ENTRYPOINT_DIR" fi - exec gosu odoo "$@" + exec su-exec odoo "$@" fi exec "$@" diff --git a/bin/runmigration b/bin/runmigration index ca1bc2ad..3f0a8b28 100755 --- a/bin/runmigration +++ b/bin/runmigration @@ -71,7 +71,7 @@ else echo "Do migration from scratch 🐢 🐢 🐢" fi -gosu odoo migrate +su-exec odoo migrate # Create a dump if none exist for the current VERSION if [ "$CREATE_DB_CACHE" == "true" -a ! -f "$CACHED_DUMP" ]; then diff --git a/bin/runtests b/bin/runtests index 6fec8c8e..c0e4c092 100755 --- a/bin/runtests +++ b/bin/runtests @@ -72,7 +72,7 @@ else echo "No cached dump found matching MD5 🐢 🐢 🐢" fi echo "🔨🔨 Install official/OCA modules 🔨🔨" - gosu odoo odoo --stop-after-init --workers=0 --database $DB_NAME_TEST --log-level=warn --without-demo="" --db-filter=$DB_NAME_TEST -i ${DEPS_ADDONS} + su-exec odoo odoo --stop-after-init --workers=0 --database $DB_NAME_TEST --log-level=warn --without-demo="" --db-filter=$DB_NAME_TEST -i ${DEPS_ADDONS} if [ "$CREATE_DB_CACHE" == "true" -a ! -z "$CACHED_DUMP" ]; then echo "Generate dump $CACHED_DUMP into cache 🐘⮕ 📦" mkdir -p "$CACHE_DIR" @@ -80,10 +80,10 @@ else fi fi echo "🔧🔧 Install local-src modules 🔧🔧" -gosu odoo odoo --stop-after-init --workers=0 --database $DB_NAME_TEST --log-level=warn --without-demo="" --db-filter=$DB_NAME_TEST -i ${LOCAL_ADDONS} +su-exec odoo odoo --stop-after-init --workers=0 --database $DB_NAME_TEST --log-level=warn --without-demo="" --db-filter=$DB_NAME_TEST -i ${LOCAL_ADDONS} export COVERAGE_FILE=/home/odoo/.coverage -gosu odoo coverage run --source="${LOCAL_SRC_DIR}" "${ODOO_BIN_PATH}" --stop-after-init --workers=0 --database $DB_NAME_TEST --test-enable --log-level=test --log-handler=":INFO" --db-filter=$DB_NAME_TEST -u ${LOCAL_ADDONS} +su-exec odoo coverage run --source="${LOCAL_SRC_DIR}" "${ODOO_BIN_PATH}" --stop-after-init --workers=0 --database $DB_NAME_TEST --test-enable --log-level=test --log-handler=":INFO" --db-filter=$DB_NAME_TEST -u ${LOCAL_ADDONS} dropdb ${DB_NAME_TEST} coverage report -m diff --git a/bin/testdb-gen b/bin/testdb-gen index e4a1be4a..ee8e17ed 100755 --- a/bin/testdb-gen +++ b/bin/testdb-gen @@ -16,5 +16,5 @@ fi echo "creating database ${DB_NAME}" createdb -h ${DB_HOST} -O ${DB_USER} ${DB_NAME} -gosu odoo odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" +su-exec odoo odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" echo "done" diff --git a/bin/testdb-update b/bin/testdb-update index a260d82c..e31fb9f6 100755 --- a/bin/testdb-update +++ b/bin/testdb-update @@ -15,5 +15,5 @@ if ! psql -lqtA -h ${DB_HOST} | grep -q "^$DB_NAME|"; then fi echo "updating database ${DB_NAME}" -gosu odoo odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" +su-exec odoo odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" echo "done"