Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp: su-exec from gosu (for amd64 on arm emulation) #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions 14.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 33 additions & 1 deletion 15.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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
Expand All @@ -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 "$@"
2 changes: 1 addition & 1 deletion bin/runmigration
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions bin/runtests
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ 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"
pg_dump -Fp -d $DB_NAME_TEST -O -f "$CACHED_DUMP"
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
2 changes: 1 addition & 1 deletion bin/testdb-gen
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion bin/testdb-update
Original file line number Diff line number Diff line change
Expand Up @@ -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"