Skip to content
Merged
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
16 changes: 9 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,26 @@ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
``build_docker`` pipeline instead.

Optional tools (``--build-env-args``)
=====================================
Optional build steps (``--build-env-args``)
===========================================

Some development tools are **not** installed by default. They are enabled with
a flag passed as a build environment variable using ``--build-env-args``, which
generates an ``ENV <FLAG>=TRUE`` line in the Dockerfile. If the flag is not
defined, the installation step is skipped.
Some development tools and build steps are **not** enabled by default. They are
enabled with a flag passed as a build environment variable using
``--build-env-args``, which generates an ``ENV <FLAG>=TRUE`` line in the
Dockerfile. If the flag is not defined, the step is skipped.

.. list-table::
:widths: 30 70
:header-rows: 1

* - Flag
- Installs
- Enables
* - ``VIM_INSTALL``
- vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration
* - ``ZSH_INSTALL``
- zsh + oh-my-zsh with the ``odoo-shippable`` theme
* - ``CHOWN_UID_GID``
- Aligns the odoo user UID/GID to 5410 to match OrchestSH images. Slow: it re-chowns the whole filesystem

Example enabling more than one::

Expand Down
22 changes: 18 additions & 4 deletions src/travis2docker/templates/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,35 @@ set_odoo_ids(){
# OrchestSH images (ORCHESTSH=True) use UID/GID 5410 for the odoo user;
# older images use 1000/1001. A mismatch causes permission issues when
# sharing files across containers, so align both to 5410 when they differ.
if [ -z ${CHOWN_UID_GID+x} ];
then
echo "CHOWN_UID_GID was not defined. Skipping odoo UID/GID alignment. Use t2d parameter --build-env-args=CHOWN_UID_GID to be autoconfigured."
return 0;
fi
CURRENT_UID=$(id -u odoo)
CURRENT_GID=$(id -g odoo)
NEW_ID=5410
if [ "${CURRENT_UID}" = "${NEW_ID}" ] && [ "${CURRENT_GID}" = "${NEW_ID}" ]; then
echo "odoo UID/GID already set to ${NEW_ID}. Nothing to do."
return 0;
fi
if [ "${CURRENT_GID}" != "${NEW_ID}" ]; then
echo "Changing odoo GID from ${CURRENT_GID} to ${NEW_ID}"
groupmod -g "${NEW_ID}" odoo
# groupmod does not re-chown any file
find / -xdev -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + 2>/dev/null || true
fi
if [ "${CURRENT_UID}" != "${NEW_ID}" ]; then
echo "Changing odoo UID from ${CURRENT_UID} to ${NEW_ID}"
usermod -u "${NEW_ID}" odoo
# usermod only re-chowns files inside the home directory
find / -xdev -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + 2>/dev/null || true
fi
# groupmod does not re-chown any file and usermod only re-chowns files inside
# the home directory, so the leftovers are re-chowned here. Both predicates are
# evaluated in a single filesystem traversal using the "," operator: walking the
# whole filesystem twice is what makes this step slow. The branch whose ID did
# not change simply re-applies the very same ID, so it is a no-op.
find / -xdev \
\( -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + \) , \
\( -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + \) \
2>/dev/null || true
}

configure_vim(){
Expand Down
2 changes: 1 addition & 1 deletion src/travis2docker/travis2docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def copy_path(self, path):
if src.is_dir():
try:
shutil.copytree(src, dest_path)
except shutil.Error: # pylint: disable=except-pass
except shutil.Error: # ruff: ignore[except-pass]
pass # There are permissions errors to copy
elif src.is_file():
shutil.copy(src, dest_path)
Expand Down
Loading