Skip to content
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
8 changes: 0 additions & 8 deletions src/travis2docker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,6 @@ def main(return_result=False):
stdout.write('\nGenerated scripts:\n%s\n' % fname_list)
if deployv:
stdout.write("=" * 80)
stdout.write(
'\nUsing --deployv option you will need to run the following extra step '
'manually after to create the container or after running 20-run.sh script'
)
stdout.write(
'\ndocker exec -it --user=root CONTAINER '
'find /home/odoo -maxdepth 1 -not -user odoo -exec chown -R odoo:odoo {} \\;\n'
)
if not default_docker_image:
# TODO: Add the URL to open the pipelines
stdout.write(
Expand Down
6 changes: 1 addition & 5 deletions src/travis2docker/templates/Dockerfile_deployv
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM {{ image }}

ARG HOME=/home/odoo

# rm -rf /home/odoo/.ssh

{%- for src, dest in copies or [] %}
COPY {{ src }} {{ dest }}
{% endfor -%}
Expand Down Expand Up @@ -43,10 +41,8 @@ RUN . /home/odoo/build.sh && \
RUN {{ step }}
{% endfor %}

USER {{ user }}

# TODO: Use .profile as bash profiler by default

ENTRYPOINT /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh", "--docker"]

WORKDIR $MAIN_REPO_FULL_PATH
39 changes: 37 additions & 2 deletions src/travis2docker/templates/entrypoint_deployv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
from __future__ import print_function

import os
import sys
import subprocess
import time
import pwd


def fix_permissions():
"""Fix file permissions into the HOME directory of the odoo user.

Since the parent image marks some directories as volumes (e.g. ~/.ssh), permissions can't be fixed during
build.
"""
if not is_root():
return
print("* Fixing file permissions...")
chown_cmd = [
"find",
"/home/odoo",
"-maxdepth", "1",
"-not", "-user", "odoo",
"-exec", "chown", "-Rv", "odoo:odoo", "{}", "+",
]
result = subprocess.run(chown_cmd)


def start_psql():
# Start postgresql service
if not str2bool(os.environ.get("START_PSQL", True)):
Expand Down Expand Up @@ -82,6 +102,10 @@ def str2bool(string):
return str(string or "").lower() in ["1", "true", "yes"]


def cmd_as_user(cmd, user):
return ["sudo", "-u", user] + cmd


def start_odoo():
if not str2bool(os.environ.get("START_ODOO", True)):
return
Expand All @@ -95,8 +119,8 @@ def start_odoo():
"SELECT 1 FROM res_users LIMIT 1;",
]
if is_root():
cmd = ["sudo", "-u", "odoo"] + cmd
psql_cmd = ["sudo", "-u", "postgres"] + psql_cmd
cmd = cmd_as_user(cmd, "odoo")
psql_cmd = cmd_as_user(psql_cmd, "postgres")

try:
subprocess.check_output(psql_cmd)
Expand All @@ -119,7 +143,18 @@ def start_ssh():
subprocess.call("/etc/init.d/ssh start", shell=True)


def start_bash():
# Start bash only if it's run as a docker entrypoint (not by the user) and Odoo was asked to don't start
if "--docker" not in sys.argv or str2bool(os.environ.get("START_ODOO", True)):
return
print("Starting shell")
cmd_bash = ["su", "odoo"] if is_root() else ["bash"]
os.execvp(cmd_bash[0], cmd_bash)


if __name__ == "__main__":
fix_permissions()
start_ssh()
start_psql()
start_odoo()
start_bash()
Copy link
Collaborator

@moylop260 moylop260 Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start_odoo is not starting and odoo without --stop-after-init

Then you will use a ctrl+C to stop it

So, start_bash will not be even executed

Also, when you have already generated the container (stop and start)
it is using the odoo user and it will not have permissions to change the files permissions (That is the main problem)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moylop260

This flow is as follows:

  • Run as root
  • Fix permissions
  • Start SSH service (optional and only when run as root)
  • Start PSQL service (optional)
  • Then, using the odoo user, either:
    • Start the Odoo service
    • Or enter in interactive mode, i.e. launch the shell

The idea is to avoid having to pass --entrypoint=bash in order to use the container for developments, we would just need to ask the container to don't start the Odoo service automatically, which will launch the shell.

Regarding this:

start_odoo is not starting and odoo without --stop-after-init

The entrypoint adds --stop-after-init to the Odoo command whenever creating a new database (I didn't change that). Besides, when launching the shell, the Odoo service is not started anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luisg123v

Do you think this affects runbot?

I mean, runbot run 3 steps:

  1. Build docker image
  2. Run container with Odoo start to install modules
  3. Run container with Odoo start odoo without stop to let it alive

Loading