[REF] Set correct dockerfile, based on odoo/debian ones. (for 12 to 15)

This commit is contained in:
Sylvain LE GAL 2022-07-11 13:43:55 +02:00
parent 590f92a1c9
commit be74ce5bab
10 changed files with 302 additions and 81 deletions

View File

@ -3,7 +3,6 @@ from pathlib import Path
import click
from odoo_openupgrade_wizard.configuration_version_dependant import (
get_odoo_version_template_value,
get_odoo_versions,
get_version_options,
)
@ -139,14 +138,14 @@ def init(
# Create python requirements file
ensure_file_exists_from_template(
path_version / Path("python_requirements.txt"),
"odoo/python_requirements.txt.j2",
path_version / Path("extra_python_requirements.txt"),
"odoo/extra_python_requirements.txt.j2",
)
# Create debian requirements file
ensure_file_exists_from_template(
path_version / Path("debian_requirements.txt"),
"odoo/debian_requirements.txt.j2",
path_version / Path("extra_debian_requirements.txt"),
"odoo/extra_debian_requirements.txt.j2",
)
# Create odoo config file
@ -166,17 +165,7 @@ def init(
# Create Dockerfile file
ensure_file_exists_from_template(
path_version / Path("Dockerfile"),
"odoo/Dockerfile.j2",
odoo_version=odoo_version,
python_major_version=get_odoo_version_template_value(
odoo_version, "python_major_version"
),
python_minor_version_short=get_odoo_version_template_value(
odoo_version, "python_minor_version_short"
),
prebuild_wheel_url=get_odoo_version_template_value(
odoo_version, "prebuild_wheel_url"
),
f"odoo/{odoo_version}/Dockerfile",
)
# Create 'src' folder that will contain all the odoo code

View File

@ -5,74 +5,31 @@ from loguru import logger
_ODOO_VERSION_TEMPLATES = [
{
"version": 8.0,
"python_major_version": "python2",
"python_minor_version_short": "py27",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux1",
},
{
"version": 9.0,
"python_major_version": "python2",
"python_minor_version_short": "py27",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux1",
},
{
"version": 10.0,
"python_major_version": "python2",
"python_minor_version_short": "py27",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux1",
},
{
"version": 11.0,
"python_major_version": "python3",
"python_minor_version_short": "py36",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
{
"version": 12.0,
"python_major_version": "python3",
# Note: doesn't work with latest available version py37
"python_minor_version_short": "py36",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
{
"version": 13.0, # OK.
"python_major_version": "python3",
# Note: doesn't work with latest available version py37
"python_minor_version_short": "py36",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
"version": 13.0,
},
{
"version": 14.0, # OK
"python_major_version": "python3",
"python_minor_version_short": "py39",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
"version": 14.0,
},
{
"version": 15.0, # OK
"python_major_version": "python3",
"python_minor_version_short": "py39",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
"version": 15.0,
},
]
def get_odoo_version_template_value(version: float, key: str) -> str:
"""Return a value depending on a odoo given version and key.
Possible key:
- python_major_version. (python2, python3)
- python_minor_version_short. (py27, py36, ...)
- prebuild_wheel_url.
"""
version_template = False
for odoo_version_template in _ODOO_VERSION_TEMPLATES:
if odoo_version_template["version"] == version:
version_template = odoo_version_template
break
else:
raise ValueError
return version_template[key]
def get_version_options(mode: str) -> list:
"""Get options available for version click argument.
Arguments:

View File

@ -0,0 +1,69 @@
# <OOW> : Copy of https://github.com/odoo/odoo/blob/12.0/setup/package.dfdebian
FROM debian:stretch
# 1. <OOW> Official Odoo Dockerfile.
# Removing: postgresql, locales, rsync
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq && \
apt-get upgrade -qq -y && \
apt-get install -yq \
adduser \
dh-python \
packaging-dev \
postgresql-client \
python3 \
python3-babel \
python3-dateutil \
python3-decorator \
python3-docutils \
python3-gevent \
python3-html2text \
python3-pil \
python3-jinja2 \
python3-libsass \
python3-lxml \
python3-mako \
python3-mock \
python3-ofxparse \
python3-passlib \
python3-psutil \
python3-psycopg2 \
python3-pydot \
python3-pyparsing \
python3-pypdf2 \
python3-reportlab \
python3-requests \
python3-serial \
python3-suds \
python3-tz \
python3-usb \
python3-vatnumber \
python3-vobject \
python3-werkzeug \
python3-xlsxwriter \
&& rm -rf /var/lib/apt/lists/*
# 2. <OOW> Add 2 python dependency files and 1 debian dependency file
COPY ./src/odoo/requirements.txt /odoo_python_requirements.txt
COPY extra_python_requirements.txt /extra_python_requirements.txt
COPY extra_debian_requirements.txt /extra_debian_requirements.txt
# 3. <OOW> Install Debian packages
RUN apt-get update || true \
&& apt-get install -y\
# <OOW> To allow to run pip install
python3-pip\
# <OOW> For python-ldap
libldap2-dev ldap-utils libsasl2-dev\
&& xargs apt-get install -y --no-install-recommends <extra_debian_requirements.txt \
&& rm -rf /var/lib/apt/lists/*
# 4. <OOW> Install Python librairies
RUN python3 -m pip install --no-cache-dir -r /odoo_python_requirements.txt
RUN python3 -m pip install --no-cache-dir -r /extra_python_requirements.txt
RUN useradd --uid 1000 odoo

View File

@ -0,0 +1,73 @@
# <OOW> : Copy of https://github.com/odoo/odoo/blob/13.0/setup/package.dfdebian
FROM debian:buster
# 1. <OOW> Official Odoo Dockerfile.
# Removing: postgresql, locales, rsync
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq && \
apt-get upgrade -qq -y && \
apt-get install -qq -y\
adduser \
dh-python \
packaging-dev \
postgresql-client \
python3 \
python3-babel \
python3-dateutil \
python3-decorator \
python3-docutils \
python3-gevent \
python3-pil \
python3-jinja2 \
python3-libsass \
python3-lxml \
python3-mako \
python3-mock \
python3-ofxparse \
python3-passlib \
python3-polib \
python3-psutil \
python3-psycopg2 \
python3-pydot \
python3-pyparsing \
python3-pypdf2 \
python3-qrcode \
python3-renderpm \
python3-reportlab \
python3-requests \
python3-serial \
python3-tz \
python3-usb \
python3-vatnumber \
python3-vobject \
python3-werkzeug \
python3-xlsxwriter \
python3-zeep \
&& rm -rf /var/lib/apt/lists/*
# 2. <OOW> Add 2 python dependency files and 1 debian dependency file
COPY ./src/odoo/requirements.txt /odoo_python_requirements.txt
COPY extra_python_requirements.txt /extra_python_requirements.txt
COPY extra_debian_requirements.txt /extra_debian_requirements.txt
# 3. <OOW> Install Debian packages
RUN apt-get update || true \
&& apt-get install -y\
# <OOW> To allow to run pip install
python3-pip\
# <OOW> For python-ldap
libldap2-dev ldap-utils libsasl2-dev\
# <OOW> For cffi
build-essential libssl-dev libffi-dev python-dev\
&& xargs apt-get install -y --no-install-recommends <extra_debian_requirements.txt \
&& rm -rf /var/lib/apt/lists/*
# 4. <OOW> Install Python librairies
RUN python3 -m pip install --no-cache-dir -r /odoo_python_requirements.txt
RUN python3 -m pip install --no-cache-dir -r /extra_python_requirements.txt
RUN useradd --uid 1000 odoo

View File

@ -0,0 +1,72 @@
# <OOW> : Copy of https://github.com/odoo/odoo/blob/14.0/setup/package.dfdebian
FROM debian:buster
# 1. <OOW> Official Odoo Dockerfile.
# Removing: postgresql, locales, rsync
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq && \
apt-get upgrade -qq -y && \
apt-get install -qq -y\
adduser \
dh-python \
packaging-dev \
postgresql-client \
python3 \
python3-babel \
python3-dateutil \
python3-decorator \
python3-docutils \
python3-gevent \
python3-pil \
python3-jinja2 \
python3-libsass \
python3-lxml \
python3-mako \
python3-ofxparse \
python3-passlib \
python3-polib \
python3-psutil \
python3-psycopg2 \
python3-pydot \
python3-pypdf2 \
python3-qrcode \
python3-renderpm \
python3-reportlab \
python3-requests \
python3-serial \
python3-setuptools \
python3-stdnum \
python3-tz \
python3-usb \
python3-vobject \
python3-werkzeug \
python3-xlsxwriter \
python3-zeep \
&& rm -rf /var/lib/apt/lists/*
# 2. <OOW> Add 2 python dependency files and 1 debian dependency file
COPY ./src/odoo/requirements.txt /odoo_python_requirements.txt
COPY extra_python_requirements.txt /extra_python_requirements.txt
COPY extra_debian_requirements.txt /extra_debian_requirements.txt
# 3. <OOW> Install Debian packages
RUN apt-get update || true \
&& apt-get install -y\
# <OOW> To allow to run pip install
python3-pip\
# <OOW> For python-ldap
libldap2-dev ldap-utils libsasl2-dev\
# <OOW> For cffi
build-essential libssl-dev libffi-dev python-dev\
&& xargs apt-get install -y --no-install-recommends <extra_debian_requirements.txt \
&& rm -rf /var/lib/apt/lists/*
# 4. <OOW> Install Python librairies
RUN python3 -m pip install --no-cache-dir -r /odoo_python_requirements.txt
RUN python3 -m pip install --no-cache-dir -r /extra_python_requirements.txt
RUN useradd --uid 1000 odoo

View File

@ -0,0 +1,70 @@
# <OOW> : Copy of https://github.com/odoo/odoo/blob/15.0/setup/package.dfdebian
FROM debian:bullseye
# 1. <OOW> Official Odoo Dockerfile.
# Removing: postgresql, locales, rsync
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq && \
apt-get upgrade -qq -y && \
apt-get install -qq -y\
adduser \
dh-python \
packaging-dev \
postgresql-client \
python3 \
python3-babel \
python3-dateutil \
python3-decorator \
python3-docutils \
python3-gevent \
python3-pil \
python3-jinja2 \
python3-libsass \
python3-lxml \
python3-ofxparse \
python3-passlib \
python3-polib \
python3-psutil \
python3-psycopg2 \
python3-pydot \
python3-openssl \
python3-pypdf2 \
python3-qrcode \
python3-renderpm \
python3-reportlab \
python3-requests \
python3-serial \
python3-setuptools \
python3-stdnum \
python3-tz \
python3-usb \
python3-vobject \
python3-werkzeug \
python3-xlsxwriter \
python3-zeep \
&& rm -rf /var/lib/apt/lists/*
# 2. <OOW> Add 2 python dependency files and 1 debian dependency file
COPY ./src/odoo/requirements.txt /odoo_python_requirements.txt
COPY extra_python_requirements.txt /extra_python_requirements.txt
COPY extra_debian_requirements.txt /extra_debian_requirements.txt
# 3. <OOW> Install Debian packages
RUN apt-get update || true \
&& apt-get install -y\
# <OOW> To allow to run pip install
python3-pip\
# <OOW> For python-ldap
libldap2-dev ldap-utils libsasl2-dev\
&& xargs apt-get install -y --no-install-recommends <extra_debian_requirements.txt \
&& rm -rf /var/lib/apt/lists/*
# 4. <OOW> Install Python librairies
RUN python3 -m pip install --no-cache-dir -r /odoo_python_requirements.txt
RUN python3 -m pip install --no-cache-dir -r /extra_python_requirements.txt
RUN useradd --uid 1000 odoo

View File

@ -1,14 +0,0 @@
FROM ghcr.io/acsone/odoo-bedrock:{{ odoo_version }}-{{python_minor_version_short}}-latest
COPY ./src/odoo/requirements.txt /odoo_requirements.txt
COPY python_requirements.txt /python_requirements.txt
COPY debian_requirements.txt /debian_requirements.txt
# 2. Install extra debian packages
RUN apt-get update || true \
&& xargs apt-get install -y --no-install-recommends <debian_requirements.txt \
&& rm -rf /var/lib/apt/lists/*
# 3. Install extra Python librairies
RUN /odoo/bin/pip install --no-cache-dir -r /odoo_requirements.txt -f {{ prebuild_wheel_url }}
RUN odoo/bin/pip install --no-cache-dir -r /python_requirements.txt

View File

@ -1,7 +1,3 @@
{%- for python_librairy in python_libraries -%}
{{ python_librairy }}
{%- endfor -%}
# Mandatory library used in all odoo-openupgrade-wizard
openupgradelib

View File

@ -50,7 +50,16 @@ def ensure_file_exists_from_template(
template_folder = (
importlib_resources.files("odoo_openupgrade_wizard") / "templates"
)
text = (template_folder / template_name).read_text()
template_path = template_folder / template_name
if not template_path.exists():
logger.warning(
f"Unable to generate {file_path},"
f" the template {template_name} has not been found."
f" If it's a Dockerfile,"
f" you should maybe contribute to that project ;-)"
)
return
text = template_path.read_text()
template = Template(text)
output = template.render(args)