iterativo-git / dockerdoo

Flexible and streamlined Odoo image to be used with docker-compose, docker swarm or Kubernetes. Fully integrated to with VSCode devcontainers
MIT License
95 stars 91 forks source link

pkg_resources.DistributionNotFound odoo==15.0 #141

Closed dev-flti closed 2 years ago

dev-flti commented 2 years ago

Hey,

i tried to get dockerdoo working with odoo version 15.0.

Currently i am stuck with this error message after starting docker-compose up:

image

I Changed the Dockerfile:

FROM python:3.8-slim-buster as base

SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
USER root
# Library versions
ARG WKHTMLTOX_VERSION
ENV WKHTMLTOX_VERSION ${WKHTMLTOX_VERSION:-"0.12.5"}
ARG WKHTMLTOPDF_CHECKSUM
ENV WKHTMLTOPDF_CHECKSUM ${WKHTMLTOPDF_CHECKSUM:-"1140b0ab02aa6e17346af2f14ed0de807376de475ba90e1db3975f112fbd20bb"}
# Use noninteractive to get rid of apt-utils message
ENV DEBIAN_FRONTEND=noninteractive
# Install odoo deps
RUN apt-get -qq update \
    && apt-get -qq install -y --no-install-recommends \
    curl \
    && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/${WKHTMLTOX_VERSION}/wkhtmltox_${WKHTMLTOX_VERSION}-1.stretch_amd64.deb \
    && echo "${WKHTMLTOPDF_CHECKSUM} wkhtmltox.deb" | sha256sum -c - \
    && apt-get install -y --no-install-recommends ./wkhtmltox.deb \
    && apt-get -qq install -y --no-install-recommends \
    ca-certificates \
    chromium \
    git-core \
    gnupg \
    ffmpeg \
    fonts-liberation2 \
    fonts-noto-cjk \
    locales \
    lsb-release \
    node-less \
    npm \
    python3-renderpm \
    python3-setuptools \
    python3-slugify \
    python3-watchdog \
    python3-xlwt \
    python3-openssl \
    nano \
    ssh \
    # Add sudo support for the non-root user & unzip for CI
    sudo \
    unzip \
    vim \
    zip \
    zlibc \
    xz-utils \
    && echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-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 \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* wkhtmltox.deb /tmp/*
# Install rtlcss (on Debian buster)
RUN npm install -g rtlcss \
    && rm -Rf ~/.npm /tmp/*
FROM base as builder
# Install hard & soft build dependencies
RUN apt-get -qq update \
    && apt-get -qq install -y --no-install-recommends \
    apt-utils dialog \
    apt-transport-https \
    build-essential \
    libfreetype6-dev \
    libfribidi-dev \
    libghc-zlib-dev \
    libharfbuzz-dev \
    libjpeg-dev \
    libgeoip-dev \
    libmaxminddb-dev \
    liblcms2-dev \
    libldap2-dev \
    libopenjp2-7-dev \
    libssl-dev \
    libsasl2-dev \
    libtiff5-dev \
    libxml2-dev \
    libxslt1-dev \
    libpq-dev \
    libwebp-dev \
    lsb-release \
    tcl-dev \
    tk-dev \
    zlib1g-dev \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* /tmp/*
# Install Odoo source code and install it as a package inside the container with additional tools
ENV ODOO_VERSION ${ODOO_VERSION:-15.0}
RUN pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade --requirement https://raw.githubusercontent.com/odoo/odoo/15.0/requirements.txt \
    && pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
    astor \
    black \
    pylint-odoo \
    flake8 \
    debugpy \
    psycogreen \
    python-magic \
    phonenumbers \
    num2words \
    qrcode \
    vobject \
    xlrd \
    python-stdnum \
    click-odoo-contrib \
    git-aggregator \
    inotify \
    python-json-logger \
    wdb \
    websocket-client \
    redis \
    && (python3 -m compileall -q /usr/local || true) \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* /tmp/*
RUN git clone --depth 100 -b 15.0 https://github.com/odoo/odoo.git /opt/odoo \
    && pip3 install --editable /opt/odoo \
    && pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
    Werkzeug==0.15.6 \
    && (python3 -m compileall -q /usr/local || true) \
    && rm -Rf /var/lib/apt/lists/* /tmp/*
RUN pip3 install odoo==15.0
FROM base as production
# PIP auto-install requirements.txt (change value to "1" to auto-install)
ENV PIP_AUTO_INSTALL=${PIP_AUTO_INSTALL:-"0"}
# Run tests for all the modules in the custom addons
ENV RUN_TESTS=${RUN_TESTS:-"0"}
# Create app user
ENV ODOO_USER odoo
ENV ODOO_BASEPATH ${ODOO_BASEPATH:-/opt/odoo}
ARG APP_UID
ENV APP_UID ${APP_UID:-1000}
ARG APP_GID
ENV APP_GID ${APP_UID:-1000}
RUN addgroup --system --gid ${APP_GID} ${ODOO_USER} \
    && adduser --system --uid ${APP_UID} --ingroup ${ODOO_USER} --home ${ODOO_BASEPATH} --disabled-login --shell /sbin/nologin ${ODOO_USER} \
    && sudo usermod -aG sudo ${ODOO_USER}\
    && sudo usermod -aG root ${ODOO_USER}\
    && echo ${ODOO_USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
    && echo ${ODOO_USER} ALL=\(sudo\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
    && chmod 0440 /etc/sudoers.d/${ODOO_USER} 

# Odoo Configuration file defaults
ENV \
    ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} \
    ODOO_DATA_DIR=${ODOO_DATA_DIR:-/var/lib/odoo/data} \
    DB_PORT_5432_TCP_ADDR=${DB_PORT_5432_TCP_ADDR:-db} \
    DB_MAXCONN=${DB_MAXCONN:-64} \
    DB_ENV_POSTGRES_PASSWORD=${DB_ENV_POSTGRES_PASSWORD:-odoo} \
    DB_PORT_5432_TCP_PORT=${DB_PORT_5432_TCP_PORT:-5432} \
    DB_SSLMODE=${DB_SSLMODE:-prefer} \
    DB_TEMPLATE=${DB_TEMPLATE:-template1} \
    DB_ENV_POSTGRES_USER=${DB_ENV_POSTGRES_USER:-odoo} \
    DBFILTER=${DBFILTER:-.*} \
    HTTP_INTERFACE=${HTTP_INTERFACE:-0.0.0.0} \
    HTTP_PORT=${HTTP_PORT:-8069} \
    LIMIT_REQUEST=${LIMIT_REQUEST:-8196} \
    LIMIT_MEMORY_HARD=${LIMIT_MEMORY_HARD:-2684354560} \
    LIMIT_MEMORY_SOFT=${LIMIT_MEMORY_SOFT:-2147483648} \
    LIMIT_TIME_CPU=${LIMIT_TIME_CPU:-60} \
    LIMIT_TIME_REAL=${LIMIT_TIME_REAL:-120} \
    LIMIT_TIME_REAL_CRON=${LIMIT_TIME_REAL_CRON:-0} \
    LIST_DB=${LIST_DB:-True} \
    LOG_DB=${LOG_DB:-False} \
    LOG_DB_LEVEL=${LOG_DB_LEVEL:-warning} \
    LOGFILE=${LOGFILE:-None} \
    LOG_HANDLER=${LOG_HANDLER:-:INFO} \
    LOG_LEVEL=${LOG_LEVEL:-info} \
    MAX_CRON_THREADS=${MAX_CRON_THREADS:-2} \
    PROXY_MODE=${PROXY_MODE:-False} \
    SERVER_WIDE_MODULES=${SERVER_WIDE_MODULES:-base,web} \
    SMTP_PASSWORD=${SMTP_PASSWORD:-False} \
    SMTP_PORT=${SMTP_PORT:-25} \
    SMTP_SERVER=${SMTP_SERVER:-localhost} \
    SMTP_SSL=${SMTP_SSL:-False} \
    SMTP_USER=${SMTP_USER:-False} \
    TEST_ENABLE=${TEST_ENABLE:-False} \
    UNACCENT=${UNACCENT:-False} \
    WITHOUT_DEMO=${WITHOUT_DEMO:-False} \
    WORKERS=${WORKERS:-0}
# Define all needed directories
ENV ODOO_RC ${ODOO_RC:-/etc/odoo/odoo.conf}
ENV ODOO_DATA_DIR ${ODOO_DATA_DIR:-/var/lib/odoo/data}
ENV ODOO_LOGS_DIR ${ODOO_LOGS_DIR:-/var/lib/odoo/logs}
ENV ODOO_EXTRA_ADDONS ${ODOO_EXTRA_ADDONS:-/mnt/extra-addons}
ENV ODOO_ADDONS_BASEPATH ${ODOO_BASEPATH}/addons
ENV ODOO_CMD ${ODOO_BASEPATH}/odoo-bin
RUN mkdir -p ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} ${ODOO_EXTRA_ADDONS} /etc/odoo/
VOLUME ["${ODOO_DATA_DIR}", "${ODOO_LOGS_DIR}", "${ODOO_EXTRA_ADDONS}"]
ARG EXTRA_ADDONS_PATHS
ENV EXTRA_ADDONS_PATHS ${EXTRA_ADDONS_PATHS}
ARG EXTRA_MODULES
ENV EXTRA_MODULES ${EXTRA_MODULES}
COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /usr/local /usr/local
COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /opt/odoo ${ODOO_BASEPATH}
# Copy from build env
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/entrypoint.sh /
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/getaddons.py /
# This is needed to fully build with modules and python requirements
# Copy custom modules from the custom folder, if any.
ARG HOST_CUSTOM_ADDONS
ENV HOST_CUSTOM_ADDONS ${HOST_CUSTOM_ADDONS:-./custom}
COPY --chown=${ODOO_USER}:${ODOO_USER} ${HOST_CUSTOM_ADDONS} ${ODOO_EXTRA_ADDONS}
RUN sudo chown -R ${ODOO_USER}:${ODOO_USER} /var/lib/odoo
# Own folders    //-- docker-compose creates named volumes owned by root:root. Issue: https://github.com/docker/compose/issues/3270
RUN chown -R ${ODOO_USER}:${ODOO_USER} ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} /etc/odoo
RUN chmod u+x /entrypoint.sh
EXPOSE 8069 8071 8072
# Docker healthcheck command
HEALTHCHECK CMD curl --fail http://127.0.0.1:8069/web_editor/static/src/xml/ace.xml || exit 1
ENV PGHOST ${DB_PORT_5432_TCP_ADDR}
ENV PGPORT ${DB_PORT_5432_TCP_PORT}
ENV PGUSER ${DB_ENV_POSTGRES_USER}
ENV PGPASSWORD ${DB_ENV_POSTGRES_PASSWORD}
ENTRYPOINT ["/entrypoint.sh"]

USER ${ODOO_USER}

#CMD ["odoo"]
CMD ["sh", "-c", "${ODOO_CMD}"]

Also i changed the .env file to ODOO_VERSION=15.0

Do you (@andrp92) have any ideas, how i can get it to work with the newest odoo version?

Thanks and all the best!

EDIT

This is my current docker-compose.yml (i consolidated it to one file - i just need the dev-hosted version)

version: "3.7"

networks:
  default:
    external:
      name: cloudbuild
  odoonet:

volumes:
  odoo-data:
  odoo-testlogs:
  odoo-modules:
  psql:

services:
  odoo:
    build: 
      context: .
    image: odoo15
    env_file: .env
    restart: unless-stopped
    ports: ["8069:8069", "8072:8072"]
    volumes:
      # Host paths (.ssh configuration)
      - ~/.ssh/:/opt/odoo/.ssh/:cached
      # Named volumes
      - odoo-data:${ODOO_DATA_DIR}
      - odoo-testlogs:${ODOO_LOGS_DIR}
      - ./custom:${ODOO_EXTRA_ADDONS}:delegated
      - ./src/odoo:/${ODOO_BASEPATH}:cached
      - ./config/odoo.conf:/etc/odoo/odoo.conf:cached

    environment:
      - LOG_LEVEL=debug
      - WITHOUT_DEMO=False

    depends_on:
      - db
    command: ["${ODOO_CMD}", "--dev", "reload,qweb,werkzeug,xml"]
    networks:
      odoonet:
  # ------------------------
  db:
    image: postgres:12
    restart: unless-stopped
    volumes:
      - psql:/var/lib/postgresql/data/pgdata
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_USER=${POSTGRES_USER}
      - PGDATA=/var/lib/postgresql/data/pgdata

    networks:
      odoonet:
tgoetten commented 2 years ago

Hey @dev-flti in case you haven't found the reason for error (and along with that a solution) maybe my updated Dockerfile will help you to get everything up & running.

My goal was to keep the structure of the original Dockerfile provided in this repository but update it to run Odoo version 15. On my way, I also ran into problems related to my device (M1 arm64 processor) and not installing wkhtml.

At the end, after almost 2 hours, I ended up with a version of the Dockerfile which not only can run Odoo version 15 but also works on Apples M1 processor and incorporates your improvements (removed no longer needed libraries, health check etc.)

First, you need to update the docker-compose.yaml to build the image (comment on the image line and add the build instructions)

services:
  odoo:
#    image: iterativodo/dockerdoo:${ODOO_VERSION}
    build:
      dockerfile: Dockerfile.custom
    image: iterativodo-dockerdoo:${ODOO_VERSION}
...

Second, you need to create a new file called Dockerfile.custom and paste this:

FROM python:3.8-slim-buster as base

SHELL ["/bin/bash", "-xo", "pipefail", "-c"]

USER root

# Use noninteractive to get rid of apt-utils message
ENV DEBIAN_FRONTEND=noninteractive

# Generate locale C.UTF-8 for postgres and general locale data
ENV LANG C.UTF-8

# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    dirmngr \
    fonts-noto-cjk \
    git-core \
    gnupg \
    libssl-dev \
    lsb-release \
    node-less \
    npm \
    python3-num2words \
    python3-pdfminer \
    python3-pip \
    python3-phonenumbers \
    python3-pyldap \
    python3-qrcode \
    python3-renderpm \
    python3-setuptools \
    python3-slugify \
    python3-vobject \
    python3-watchdog \
    python3-xlrd \
    python3-xlwt \
    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

# install latest postgresql-client
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-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 \
    libpq-dev \
    && 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 \
    && rm -Rf ~/.npm /tmp/*

FROM base as builder

# Install hard & soft build dependencies
RUN apt-get -qq update \
    && apt-get -qq install -y --no-install-recommends \
    apt-utils dialog \
    apt-transport-https \
    build-essential \
    libfreetype6-dev \
    libfribidi-dev \
    libghc-zlib-dev \
    libharfbuzz-dev \
    libjpeg-dev \
    libgeoip-dev \
    libmaxminddb-dev \
    liblcms2-dev \
    libldap2-dev \
    libopenjp2-7-dev \
    libssl-dev \
    libsasl2-dev \
    libtiff5-dev \
    libxml2-dev \
    libxslt1-dev \
    libwebp-dev \
    tcl-dev \
    tk-dev \
    zlib1g-dev \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* /tmp/*

# Install Odoo source code and install it as a package inside the container with additional tools
ENV ODOO_VERSION ${ODOO_VERSION:-15.0}

RUN pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade --requirement https://raw.githubusercontent.com/odoo/odoo/${ODOO_VERSION}/requirements.txt \
    && pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
    astor \
    black \
    pylint-odoo \
    flake8 \
    debugpy \
    psycogreen \
    python-magic \
    phonenumbers \
    num2words \
    qrcode \
    vobject \
    xlrd \
    python-stdnum \
    click-odoo-contrib \
    git-aggregator \
    inotify \
    python-json-logger \
    wdb \
    websocket-client \
    redis \
    && (python3 -m compileall -q /usr/local || true) \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* /tmp/*

RUN git clone --depth 100 -b ${ODOO_VERSION} https://github.com/odoo/odoo.git /opt/odoo \
    && pip3 install --editable /opt/odoo \
    && pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
    Werkzeug==0.15.6 \
    && (python3 -m compileall -q /usr/local || true) \
    && rm -Rf /var/lib/apt/lists/* /tmp/*

FROM base as production

# Install sudo
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    sudo

# PIP auto-install requirements.txt (change value to "1" to auto-install)
ENV PIP_AUTO_INSTALL=${PIP_AUTO_INSTALL:-"0"}

# Run tests for all the modules in the custom addons
ENV RUN_TESTS=${RUN_TESTS:-"0"}

# Create app user
ENV ODOO_USER odoo
ENV ODOO_BASEPATH ${ODOO_BASEPATH:-/opt/odoo}
ARG APP_UID
ENV APP_UID ${APP_UID:-1000}

ARG APP_GID
ENV APP_GID ${APP_UID:-1000}

RUN addgroup --system --gid ${APP_GID} ${ODOO_USER} \
    && adduser --system --uid ${APP_UID} --ingroup ${ODOO_USER} --home ${ODOO_BASEPATH} --disabled-login --shell /sbin/nologin ${ODOO_USER} \
    && sudo usermod -aG sudo ${ODOO_USER}\
    && sudo usermod -aG root ${ODOO_USER}\
    && echo ${ODOO_USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
    && echo ${ODOO_USER} ALL=\(sudo\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
    && chmod 0440 /etc/sudoers.d/${ODOO_USER}

    # Odoo Configuration file variables and defaults
    ARG ADMIN_PASSWORD
    ARG PGHOST
    ARG PGUSER
    ARG PGPORT
    ARG PGPASSWORD
    ARG DB_TEMPLATE
    ARG HTTP_INTERFACE
    ARG HTTP_PORT
    ARG DBFILTER
    ARG DBNAME
    ARG SERVER_WIDE_MODULES

ENV \
    ADMIN_PASSWORD=${ADMIN_PASSWORD:-my-weak-password} \
    ODOO_DATA_DIR=${ODOO_DATA_DIR:-/var/lib/odoo/data} \
    DB_PORT_5432_TCP_ADDR=${PGHOST:-db} \
    DB_MAXCONN=${DB_MAXCONN:-64} \
    DB_ENV_POSTGRES_PASSWORD=${PGPASSWORD:-odoo} \
    DB_PORT_5432_TCP_PORT=${PGPORT:-5432} \
    DB_SSLMODE=${DB_SSLMODE:-prefer} \
    DB_TEMPLATE=${DB_TEMPLATE:-template1} \
    DB_ENV_POSTGRES_USER=${PGUSER:-odoo} \
    DBFILTER=${DBFILTER:-.*} \
    DBNAME=${DBNAME} \
    HTTP_INTERFACE=${HTTP_INTERFACE:-0.0.0.0} \
    HTTP_PORT=${HTTP_PORT:-8069} \
    LIMIT_REQUEST=${LIMIT_REQUEST:-8196} \
    LIMIT_MEMORY_HARD=${LIMIT_MEMORY_HARD:-2684354560} \
    LIMIT_MEMORY_SOFT=${LIMIT_MEMORY_SOFT:-2147483648} \
    LIMIT_TIME_CPU=${LIMIT_TIME_CPU:-60} \
    LIMIT_TIME_REAL=${LIMIT_TIME_REAL:-120} \
    LIMIT_TIME_REAL_CRON=${LIMIT_TIME_REAL_CRON:-0} \
    LIST_DB=${LIST_DB:-True} \
    LOG_DB=${LOG_DB:-False} \
    LOG_DB_LEVEL=${LOG_DB_LEVEL:-warning} \
    LOGFILE=${LOGFILE:-None} \
    LOG_HANDLER=${LOG_HANDLER:-:INFO} \
    LOG_LEVEL=${LOG_LEVEL:-info} \
    MAX_CRON_THREADS=${MAX_CRON_THREADS:-2} \
    PROXY_MODE=${PROXY_MODE:-False} \
    SERVER_WIDE_MODULES=${SERVER_WIDE_MODULES:-base,web} \
    SMTP_PASSWORD=${SMTP_PASSWORD:-False} \
    SMTP_PORT=${SMTP_PORT:-25} \
    SMTP_SERVER=${SMTP_SERVER:-localhost} \
    SMTP_SSL=${SMTP_SSL:-False} \
    SMTP_USER=${SMTP_USER:-False} \
    TEST_ENABLE=${TEST_ENABLE:-False} \
    UNACCENT=${UNACCENT:-False} \
    WITHOUT_DEMO=${WITHOUT_DEMO:-False} \
    WORKERS=${WORKERS:-0}

# Define all needed directories
ENV ODOO_RC ${ODOO_RC:-/etc/odoo/odoo.conf}
ENV ODOO_DATA_DIR ${ODOO_DATA_DIR:-/var/lib/odoo/data}
ENV ODOO_LOGS_DIR ${ODOO_LOGS_DIR:-/var/lib/odoo/logs}
ENV ODOO_EXTRA_ADDONS ${ODOO_EXTRA_ADDONS:-/mnt/extra-addons}
ENV ODOO_ADDONS_BASEPATH ${ODOO_BASEPATH}/addons
ENV ODOO_CMD ${ODOO_BASEPATH}/odoo-bin

RUN mkdir -p ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} ${ODOO_EXTRA_ADDONS} /etc/odoo/
# Own folders    //-- docker-compose creates named volumes owned by root:root. Issue: https://github.com/docker/compose/issues/3270
RUN chown -R ${ODOO_USER}:${ODOO_USER} ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} /etc/odoo

VOLUME ["${ODOO_DATA_DIR}", "${ODOO_LOGS_DIR}", "${ODOO_EXTRA_ADDONS}"]

ARG EXTRA_ADDONS_PATHS
ENV EXTRA_ADDONS_PATHS ${EXTRA_ADDONS_PATHS}

ARG EXTRA_MODULES
ENV EXTRA_MODULES ${EXTRA_MODULES}

COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /usr/local /usr/local
COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /opt/odoo ${ODOO_BASEPATH}

# Copy from build env
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/entrypoint.sh /
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/getaddons.py /

# This is needed to fully build with modules and python requirements
# Copy custom modules from the custom folder, if any.
ARG HOST_CUSTOM_ADDONS
ENV HOST_CUSTOM_ADDONS ${HOST_CUSTOM_ADDONS:-./custom}
COPY --chown=${ODOO_USER}:${ODOO_USER} ${HOST_CUSTOM_ADDONS} ${ODOO_EXTRA_ADDONS}
RUN sudo chown -R ${ODOO_USER}:${ODOO_USER} /var/lib/odoo
RUN chmod u+x /entrypoint.sh

EXPOSE 8069 8071 8072

# Docker healthcheck command
HEALTHCHECK CMD curl --fail http://127.0.0.1:8069/web_editor/static/src/xml/ace.xml || exit 1
ENV PGHOST ${DB_PORT_5432_TCP_ADDR}
ENV PGPORT ${DB_PORT_5432_TCP_PORT}
ENV PGUSER ${DB_ENV_POSTGRES_USER}
ENV PGPASSWORD ${DB_ENV_POSTGRES_PASSWORD}

ENTRYPOINT ["/entrypoint.sh"]

USER ${ODOO_USER}

CMD ["sh", "-c", "${ODOO_CMD}"]

Let me know if that helped solving you problem?

dev-flti commented 2 years ago

Hi @tgoetten ,

thank you for your answer! unfortunately still got the same error The 'odoo==15.0' distribution was not found and is required by the application -> changed the the yaml and created a new Dockerfile

after having the entrypoint error is changed the last lines of the current entrypoint.sh

        ;;
    -*)
        exec odoo "$@" "${DB_ARGS[@]}"
        ;;
    *)
        exec "$@"
esac

exit 1

to

        ;;
    -*)
        exec odoo "$@" "${DB_ARGS[@]}"
        ;;
    *)
        exec odoo "$@"
esac

exit 1

After running it again, the distribution error showed up again.. any further ideas?

Have the same setup: Macbook Pro and m-Chip ..

Here is the current Dockerfile i use:


SHELL ["/bin/bash", "-xo", "pipefail", "-c"]

USER root

# Use noninteractive to get rid of apt-utils message
ENV DEBIAN_FRONTEND=noninteractive

# Generate locale C.UTF-8 for postgres and general locale data
ENV LANG C.UTF-8

# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    dirmngr \
    fonts-noto-cjk \
    git-core \
    gnupg \
    libssl-dev \
    lsb-release \
    node-less \
    npm \
    python3-num2words \
    python3-pdfminer \
    python3-pip \
    python3-phonenumbers \
    python3-pyldap \
    python3-qrcode \
    python3-renderpm \
    python3-setuptools \
    python3-slugify \
    python3-vobject \
    python3-watchdog \
    python3-xlrd \
    python3-xlwt \
    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

# install latest postgresql-client
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-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 \
    libpq-dev \
    && 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 \
    && rm -Rf ~/.npm /tmp/*

FROM base as builder

# Install hard & soft build dependencies
RUN apt-get -qq update \
    && apt-get -qq install -y --no-install-recommends \
    apt-utils dialog \
    apt-transport-https \
    build-essential \
    libfreetype6-dev \
    libfribidi-dev \
    libghc-zlib-dev \
    libharfbuzz-dev \
    libjpeg-dev \
    libgeoip-dev \
    libmaxminddb-dev \
    liblcms2-dev \
    libldap2-dev \
    libopenjp2-7-dev \
    libssl-dev \
    libsasl2-dev \
    libtiff5-dev \
    libxml2-dev \
    libxslt1-dev \
    libwebp-dev \
    tcl-dev \
    tk-dev \
    zlib1g-dev \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* /tmp/*

# Install Odoo source code and install it as a package inside the container with additional tools
ENV ODOO_VERSION ${ODOO_VERSION:-15.0}

RUN pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade --requirement https://raw.githubusercontent.com/odoo/odoo/${ODOO_VERSION}/requirements.txt \
    && pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
    astor \
    black \
    pylint-odoo \
    flake8 \
    debugpy \
    psycogreen \
    python-magic \
    phonenumbers \
    num2words \
    qrcode \
    vobject \
    xlrd \
    python-stdnum \
    click-odoo-contrib \
    git-aggregator \
    inotify \
    python-json-logger \
    wdb \
    websocket-client \
    redis \
    && (python3 -m compileall -q /usr/local || true) \
    && apt-get autopurge -yqq \
    && rm -Rf /var/lib/apt/lists/* /tmp/*

RUN git clone --depth 100 -b ${ODOO_VERSION} https://github.com/odoo/odoo.git /opt/odoo \
    && pip3 install --editable /opt/odoo \
    && pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
    Werkzeug==0.15.6 \
    && (python3 -m compileall -q /usr/local || true) \
    && rm -Rf /var/lib/apt/lists/* /tmp/*

FROM base as production

# Install sudo
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    sudo

# PIP auto-install requirements.txt (change value to "1" to auto-install)
ENV PIP_AUTO_INSTALL=${PIP_AUTO_INSTALL:-"0"}

# Run tests for all the modules in the custom addons
ENV RUN_TESTS=${RUN_TESTS:-"0"}

# Create app user
ENV ODOO_USER odoo
ENV ODOO_BASEPATH ${ODOO_BASEPATH:-/opt/odoo}
ARG APP_UID
ENV APP_UID ${APP_UID:-1000}

ARG APP_GID
ENV APP_GID ${APP_UID:-1000}

RUN addgroup --system --gid ${APP_GID} ${ODOO_USER} \
    && adduser --system --uid ${APP_UID} --ingroup ${ODOO_USER} --home ${ODOO_BASEPATH} --disabled-login --shell /sbin/nologin ${ODOO_USER} \
    && sudo usermod -aG sudo ${ODOO_USER}\
    && sudo usermod -aG root ${ODOO_USER}\
    && echo ${ODOO_USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
    && echo ${ODOO_USER} ALL=\(sudo\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
    && chmod 0440 /etc/sudoers.d/${ODOO_USER}

    # Odoo Configuration file variables and defaults
    ARG ADMIN_PASSWORD
    ARG PGHOST
    ARG PGUSER
    ARG PGPORT
    ARG PGPASSWORD
    ARG DB_TEMPLATE
    ARG HTTP_INTERFACE
    ARG HTTP_PORT
    ARG DBFILTER
    ARG DBNAME
    ARG SERVER_WIDE_MODULES

ENV \
    ADMIN_PASSWORD=${ADMIN_PASSWORD:-my-weak-password} \
    ODOO_DATA_DIR=${ODOO_DATA_DIR:-/var/lib/odoo/data} \
    DB_PORT_5432_TCP_ADDR=${PGHOST:-db} \
    DB_MAXCONN=${DB_MAXCONN:-64} \
    DB_ENV_POSTGRES_PASSWORD=${PGPASSWORD:-odoo} \
    DB_PORT_5432_TCP_PORT=${PGPORT:-5432} \
    DB_SSLMODE=${DB_SSLMODE:-prefer} \
    DB_TEMPLATE=${DB_TEMPLATE:-template1} \
    DB_ENV_POSTGRES_USER=${PGUSER:-odoo} \
    DBFILTER=${DBFILTER:-.*} \
    DBNAME=${DBNAME} \
    HTTP_INTERFACE=${HTTP_INTERFACE:-0.0.0.0} \
    HTTP_PORT=${HTTP_PORT:-8069} \
    LIMIT_REQUEST=${LIMIT_REQUEST:-8196} \
    LIMIT_MEMORY_HARD=${LIMIT_MEMORY_HARD:-2684354560} \
    LIMIT_MEMORY_SOFT=${LIMIT_MEMORY_SOFT:-2147483648} \
    LIMIT_TIME_CPU=${LIMIT_TIME_CPU:-60} \
    LIMIT_TIME_REAL=${LIMIT_TIME_REAL:-120} \
    LIMIT_TIME_REAL_CRON=${LIMIT_TIME_REAL_CRON:-0} \
    LIST_DB=${LIST_DB:-True} \
    LOG_DB=${LOG_DB:-False} \
    LOG_DB_LEVEL=${LOG_DB_LEVEL:-warning} \
    LOGFILE=${LOGFILE:-None} \
    LOG_HANDLER=${LOG_HANDLER:-:INFO} \
    LOG_LEVEL=${LOG_LEVEL:-info} \
    MAX_CRON_THREADS=${MAX_CRON_THREADS:-2} \
    PROXY_MODE=${PROXY_MODE:-False} \
    SERVER_WIDE_MODULES=${SERVER_WIDE_MODULES:-base,web} \
    SMTP_PASSWORD=${SMTP_PASSWORD:-False} \
    SMTP_PORT=${SMTP_PORT:-25} \
    SMTP_SERVER=${SMTP_SERVER:-localhost} \
    SMTP_SSL=${SMTP_SSL:-False} \
    SMTP_USER=${SMTP_USER:-False} \
    TEST_ENABLE=${TEST_ENABLE:-False} \
    UNACCENT=${UNACCENT:-False} \
    WITHOUT_DEMO=${WITHOUT_DEMO:-False} \
    WORKERS=${WORKERS:-0}

# Define all needed directories
ENV ODOO_RC ${ODOO_RC:-/etc/odoo/odoo.conf}
ENV ODOO_DATA_DIR ${ODOO_DATA_DIR:-/var/lib/odoo/data}
ENV ODOO_LOGS_DIR ${ODOO_LOGS_DIR:-/var/lib/odoo/logs}
ENV ODOO_EXTRA_ADDONS ${ODOO_EXTRA_ADDONS:-/mnt/extra-addons}
ENV ODOO_ADDONS_BASEPATH ${ODOO_BASEPATH}/addons
ENV ODOO_CMD ${ODOO_BASEPATH}/odoo-bin

RUN mkdir -p ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} ${ODOO_EXTRA_ADDONS} /etc/odoo/
# Own folders    //-- docker-compose creates named volumes owned by root:root. Issue: https://github.com/docker/compose/issues/3270
RUN chown -R ${ODOO_USER}:${ODOO_USER} ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} /etc/odoo

VOLUME ["${ODOO_DATA_DIR}", "${ODOO_LOGS_DIR}", "${ODOO_EXTRA_ADDONS}"]

ARG EXTRA_ADDONS_PATHS
ENV EXTRA_ADDONS_PATHS ${EXTRA_ADDONS_PATHS}

ARG EXTRA_MODULES
ENV EXTRA_MODULES ${EXTRA_MODULES}

COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /usr/local /usr/local
COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /opt/odoo ${ODOO_BASEPATH}

# Copy from build env
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/entrypoint.sh /
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/getaddons.py /

# This is needed to fully build with modules and python requirements
# Copy custom modules from the custom folder, if any.
ARG HOST_CUSTOM_ADDONS
ENV HOST_CUSTOM_ADDONS ${HOST_CUSTOM_ADDONS:-./custom}
COPY --chown=${ODOO_USER}:${ODOO_USER} ${HOST_CUSTOM_ADDONS} ${ODOO_EXTRA_ADDONS}
RUN sudo chown -R ${ODOO_USER}:${ODOO_USER} /var/lib/odoo
RUN chmod 777 /entrypoint.sh

EXPOSE 8069 8071 8072

# Docker healthcheck command
HEALTHCHECK CMD curl --fail http://127.0.0.1:8069/web_editor/static/src/xml/ace.xml || exit 1
ENV PGHOST ${DB_PORT_5432_TCP_ADDR}
ENV PGPORT ${DB_PORT_5432_TCP_PORT}
ENV PGUSER ${DB_ENV_POSTGRES_USER}
ENV PGPASSWORD ${DB_ENV_POSTGRES_PASSWORD}

ENTRYPOINT ["/entrypoint.sh"]

USER ${ODOO_USER}

CMD ["sh", "-c", "${ODOO_CMD}"]
gustavovalverde commented 2 years ago

Fixed by https://github.com/iterativo-git/dockerdoo/commit/468742888e7fca92a5415543e03615083be744ab

dev-flti commented 2 years ago

@gustavovalverde still got the same error

pkg_resources.DistributionNotFound: The 'odoo==15.0' distribution was not found and is required by the application
image
gustavovalverde commented 2 years ago

@dev-flti the wrong tag was being pushed to the registry. This is fixed now. Sorry for the inconvenience.