odoo / docker

Other
932 stars 1.52k forks source link

Developer features not working on Macbook Pro M1 #397

Closed floflock closed 1 week ago

floflock commented 2 years ago

The command --dev=all or --dev=reload obviously using watchdog for hot reloading. Watchdog uses inotify on Linux images for getting the file updates triggered. Apple Silicon as a host system does not support this anymore: https://docs.docker.com/desktop/mac/apple-silicon/

However, attempts to run Intel-based containers on Apple Silicon machines under emulation can crash as qemu sometimes fails to run the container. In addition, filesystem change notification APIs (inotify) do not work under qemu emulation. Even when the containers do run correctly under emulation, they will be slower and use more memory than the native equivalent.

Therefore, this is an issue with the new arm architecture shipped with the new Macbook Pro: https://github.com/gorakhargosh/watchdog/issues/838

Watchdog uses notify on linux as it is documented here: https://python-watchdog.readthedocs.io/en/stable/installation.html#supported-platforms-and-caveats

The container is not starting properly due to the same error shown in the issue above:

kaminholz_odoo_web  | 2021-11-15 14:22:33,910 1 INFO ? odoo: Odoo version 14.0-20211110
kaminholz_odoo_web  | 2021-11-15 14:22:33,912 1 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf
kaminholz_odoo_web  | 2021-11-15 14:22:33,912 1 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/14.0', '/mnt/extra-addons', '/mnt/enterprise-addons']
kaminholz_odoo_web  | 2021-11-15 14:22:33,912 1 INFO ? odoo: database: odoo@odoo_db:5432
kaminholz_odoo_web  | 2021-11-15 14:22:34,537 1 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
kaminholz_odoo_web  | 2021-11-15 14:22:34,847 1 INFO ? odoo.service.server: Watching addons folder /usr/lib/python3/dist-packages/odoo/addons
kaminholz_odoo_web  | 2021-11-15 14:22:34,847 1 INFO ? odoo.service.server: Watching addons folder /var/lib/odoo/addons/14.0
kaminholz_odoo_web  | 2021-11-15 14:22:34,848 1 INFO ? odoo.service.server: Watching addons folder /mnt/extra-addons
kaminholz_odoo_web  | 2021-11-15 14:22:34,848 1 INFO ? odoo.service.server: Watching addons folder /mnt/enterprise-addons
kaminholz_odoo_web  | Traceback (most recent call last):
kaminholz_odoo_web  |   File "/usr/bin/odoo", line 8, in <module>
kaminholz_odoo_web  |     odoo.cli.main()
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/odoo/cli/command.py", line 61, in main
kaminholz_odoo_web  |     o.run(args)
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 178, in run
kaminholz_odoo_web  |     main(args)
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/odoo/cli/server.py", line 172, in main
kaminholz_odoo_web  |     rc = odoo.service.server.start(preload=preload, stop=stop)
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 1288, in start
kaminholz_odoo_web  |     watcher.start()
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 250, in start
kaminholz_odoo_web  |     self.observer.start()
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/watchdog/observers/api.py", line 255, in start
kaminholz_odoo_web  |     emitter.start()
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/watchdog/utils/__init__.py", line 110, in start
kaminholz_odoo_web  |     self.on_thread_start()
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/watchdog/observers/inotify.py", line 121, in on_thread_start
kaminholz_odoo_web  |     self._inotify = InotifyBuffer(path, self.watch.is_recursive)
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/watchdog/observers/inotify_buffer.py", line 35, in __init__
kaminholz_odoo_web  |     self._inotify = Inotify(path, recursive)
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/watchdog/observers/inotify_c.py", line 188, in __init__
kaminholz_odoo_web  |     Inotify._raise_error()
kaminholz_odoo_web  |   File "/usr/lib/python3/dist-packages/watchdog/observers/inotify_c.py", line 417, in _raise_error
kaminholz_odoo_web  |     raise OSError(os.strerror(err))
kaminholz_odoo_web  | OSError: Function not implemented
kaminholz_odoo_web exited with code 1

Unfortunately, there is no solution right now, but I wanted to document that as more and more developers will search for this issue...

sanderkwantes commented 2 years ago

This would be resolved if #399 is merged. Failure of inotify to work in an Amd64 build (via Rosetta) is a known problem (https://docs.docker.com/desktop/mac/apple-silicon/#known-issues). The fix in the merge request allows the arm64 variant to be used. This one is also a bit more efficient.

leimantas commented 2 years ago

RUN WKH_VERSION=$([ "$(uname -m)" = 'aarch64' ] && echo "arm64" || echo "amd64") \ && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${WKH_VERSION}.deb \ && apt-get install -y --no-install-recommends ./wkhtmltox.deb \ && rm -rf /var/lib/apt/lists/* wkhtmltox.deb

Change this line: https://github.com/odoo/docker/blob/master/15.0/Dockerfile#L34 And build this on M1. All works.

gustavovalverde commented 2 years ago

I saw your approach @leimantas and used it in Dockerdoo (https://github.com/iterativo-git/dockerdoo) now we're cross-compiling all supported versions with arm64

Pexers commented 1 year ago

The solution proposed by @leimantas worked like a charm. 👌

The only downside is that we now have to build our own base Odoo Docker images instead of relying on the ones available on DockerHub.

leimantas commented 1 year ago

The solution proposed by @leimantas worked like a charm. 👌

The only downside is that we now have to build our own base Odoo Docker images instead of relying on the ones available on DockerHub.

You can build and push to docker hub. I do just like that. https://hub.docker.com/r/wbms/odoo-16.0

Pexers commented 1 year ago

You can build and push to docker hub. I do just like that. https://hub.docker.com/r/wbms/odoo-16.0

@leimantas I was referring to the official Odoo images on DockerHub, my bad.

Khant-NyarxG-Next commented 4 months ago

RUN WKH_VERSION=$([ "$(uname -m)" = 'aarch64' ] && echo "arm64" || echo "amd64") \ && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${WKH_VERSION}.deb \ && apt-get install -y --no-install-recommends ./wkhtmltox.deb \ && rm -rf /var/lib/apt/lists/* wkhtmltox.deb

Change this line: https://github.com/odoo/docker/blob/master/15.0/Dockerfile#L34 And build this on M1. All works.

could you help me

i got on error with custom docker images,inside the image i have try to get wkhtmltopdf 0.12.6 (with patched qt) but wkhtmltopdf 0.12.6 without path qt so i get these error at my odoo

odooGnext           | 2024-02-19 04:13:15,936 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="aggregated_lines[line]['name']" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,936 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="'{0:,.0f}'.format(aggregated_lines[line]['qty_ordered'])" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,936 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="aggregated_lines[line]['product_uom'].name" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,937 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="'{0:,.0f}'.format(aggregated_lines[line]['qty_done'])" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,937 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="aggregated_lines[line]['product_uom'].name" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,937 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="'{0:,.0f}'.format(aggregated_lines[line]['unit_price'])" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,937 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="'{0:,.0f}'.format(aggregated_lines[line]['subtotal'])" in template 2343. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,946 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="title or 'Odoo Report'" in template 191. Replace by @t-out
odooGnext           | 2024-02-19 04:13:15,957 1 WARNING odoo15_old odoo.addons.base.models.ir_qweb: Found deprecated directive @t-esc="title or 'Odoo Report'" in template 191. Replace by @t-out
odooGnext           | 2024-02-19 04:13:16,048 1 WARNING odoo15_old odoo.addons.base.models.ir_actions_report: wkhtmltopdf: b"The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-odoo'\nExit with code 1, due to unknown error.\n"
odooGnext           | 2024-02-19 04:13:16,049 1 ERROR odoo15_old odoo.addons.web.controllers.report: Error while generating report stock.report_deliveryslip

here is my dockerfile

FROM debian:bullseye-slim
MAINTAINER Gnext Myanmar <gnext.khantsithuphyo@gmail.com>

SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
# Generate locale C.UTF-8 for postgres and general locale data
ENV LANG C.UTF-8

# Retrieve the target architecture to install the correct wkhtmltopdf package
ARG TARGETARCH
# Set environment variables
ENV ODOO_USER=odoo \
    ODOO_HOME=/opt/odoo 
# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    ca-certificates \
    build-essential \
    curl \
    dirmngr \
    fonts-noto-cjk \
    gnupg \
    libssl-dev \
    node-less \
    npm \
    python3-magic \
    python3-num2words \
    python3-odf \
    python3-pdfminer \
    python3-pip \
    python3-phonenumbers \
    python3-pyldap \
    python3-qrcode \
    python3-renderpm \
    python3-setuptools \
    python3-slugify \
    python3-vobject \
    python3-watchdog \
    python3-xlrd \
    python3-xlwt \
    sassc\
    xz-utils && \
    RUN WKH_VERSION=$([ "$(uname -m)" = 'aarch64' ] && echo "arm64" || echo "amd64") \ && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${WKH_VERSION}.deb \ && apt-get install -y --no-install-recommends ./wkhtmltox.deb \ && rm -rf /var/lib/apt/lists/* wkhtmltox.deb    && echo 'ea8277df4297afc507c61122f3c349af142f31e5 wkhtmltox.deb' | sha1sum -c - \
    && apt-get install -y --no-install-recommends ./wkhtmltox.deb \
    && rm -rf /var/lib/apt/lists/* wkhtmltox.deb

# if [ -z "${TARGETARCH}" ]; then \
#     TARGETARCH="$(dpkg --print-architecture)"; \
# fi; \
# WKHTMLTOPDF_ARCH=${TARGETARCH} && \
# case ${TARGETARCH} in \
# "amd64") WKHTMLTOPDF_ARCH=amd64 && WKHTMLTOPDF_SHA=9df8dd7b1e99782f1cfa19aca665969bbd9cc159  ;; \
# "arm64")  WKHTMLTOPDF_SHA=58c84db46b11ba0e14abb77a32324b1c257f1f22  ;; \
# "ppc64le" | "ppc64el") WKHTMLTOPDF_ARCH=ppc64el && WKHTMLTOPDF_SHA=7ed8f6dcedf5345a3dd4eeb58dc89704d862f9cd  ;; \
# esac \
# && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bullseye_${WKHTMLTOPDF_ARCH}.deb \
# && echo ${WKHTMLTOPDF_SHA} wkhtmltox.deb | sha1sum -c - \
# && apt-get install -y --no-install-recommends ./wkhtmltox.deb \
# && rm -rf /var/lib/apt/lists/* wkhtmltox.deb

# wkhtmltopdf

# install latest postgresql-client
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' > /etc/apt/sources.list.d/pgdg.list \
    && GNUPGHOME="$(mktemp -d)" \
    && export GNUPGHOME \
    && repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' \
    && gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \
    && gpg --batch --armor --export "${repokey}" > /etc/apt/trusted.gpg.d/pgdg.gpg.asc \
    && gpgconf --kill all \
    && rm -rf "$GNUPGHOME" \
    && apt-get update  \
    && apt-get install --no-install-recommends -y postgresql-client \
    && rm -f /etc/apt/sources.list.d/pgdg.list \
    && rm -rf /var/lib/apt/lists/*

# Install rtlcss (on Debian buster)
RUN npm install -g rtlcss
RUN  apt-get update && apt-get upgrade -y 
RUN cat /etc/os-release \
    && python3 --version \
    && pip3 --version

# Create Odoo system user and home directory
RUN adduser --system --group --home=${ODOO_HOME} --shell=/bin/bash ${ODOO_USER}
COPY . /opt/odoo
# RUN pip3 install --upgrade pip && pip3 install wheel \
#     && pip3 install -r /opt/odoo/requirements.txt
RUN sed -n -e '/^Depends:/,/^Pre/ s/ python3-\(.*\),/python3-\1/p' /opt/odoo/debian/control | xargs apt-get install -y
# Copy entrypoint script and Odoo configuration file
COPY ./debian/bin/entrypoint.sh /
COPY ./debian/odoo.conf /etc/odoo/
COPY ./debian/odoo.service /etc/systemd/system/multi-user.target.wants/odoo.service

# Set permissions and Mount /var/lib/odoo to allow restoring filestore and /mnt/extra-addons for users addons
# RUN chmod 755 /etc/systemd/system/multi-user.target.wants/odoo.service \
#     && chown root: /etc/systemd/system/multi-user.target.wants/odoo.service \
#     && systemctl start odoo.service \
#     && chown odoo /etc/odoo/odoo.conf \
#     && mkdir -p /mnt/extra-addons \
#     && chown -R odoo /mnt/extra-addons
RUN chmod 755 /etc/systemd/system/multi-user.target.wants/odoo.service \
    && chown root: /etc/systemd/system/multi-user.target.wants/odoo.service \
    && chown odoo /etc/odoo/odoo.conf \
    && mkdir -p /mnt/extra-addons /var/lib/odoo/\
    && chown -R odoo /mnt/extra-addons /var/lib/odoo/\
    && chmod +x /entrypoint.sh && cd /
# && service daemon-reload \
# && service start odoo 
# && /usr/bin/systemctl enable odoo

VOLUME ["/var/lib/odoo", "/mnt/extra-addons"]

# Expose Odoo services
EXPOSE 8069 8071 8072

# Set the default config file
ENV ODOO_RC /etc/odoo/odoo.conf

COPY ./debian/bin/wait-for-psql.py /usr/local/bin/wait-for-psql.py
# Set default user when running the container
USER odoo

ENTRYPOINT ["/entrypoint.sh"]
CMD ["odoo"]
lathama commented 3 months ago

@floflock is this still an issue for you? If you do not need this issue please close it.