[REF] Dockerfiles : switch from odoo/odoo to acsone/odoo-bedrock

This commit is contained in:
Sylvain LE GAL 2022-06-27 15:56:28 +02:00
parent b3638126e0
commit 80e5e3ad87
8 changed files with 72 additions and 29 deletions

View File

@ -50,3 +50,8 @@ in modules.csv.j2 :
# TODO, this value are usefull for test for analyse between 13 and 14.
# move that values in data/extra_script/modules.csv
# and let this template with only 'base' module.
TODO when launching container :
- install odoo : ``pip install -e /odoo/src/odoo``

View File

@ -3,9 +3,10 @@ from pathlib import Path
import click
from odoo_openupgrade_wizard.configuration_version_dependant import (
get_odoo_version_settings,
get_odoo_versions,
get_python_libraries,
get_python_major_version,
get_python_minor_version_short,
get_version_options,
)
from odoo_openupgrade_wizard.tools.tools_odoo import get_odoo_env_path
@ -68,6 +69,9 @@ def init(
odoo_versions = get_odoo_versions(
float(initial_version), float(final_version)
)
odoo_version_settings = get_odoo_version_settings(
float(initial_version), float(final_version)
)
# 2. Compute Migration Steps
@ -133,6 +137,7 @@ def init(
project_name=project_name,
steps=steps,
odoo_versions=odoo_versions,
odoo_version_settings=odoo_version_settings,
)
# 7. Ensure module list file exists
@ -154,7 +159,6 @@ def init(
ensure_file_exists_from_template(
path_version / Path("python_requirements.txt"),
"odoo/python_requirements.txt.j2",
python_libraries=get_python_libraries(odoo_version),
)
# Create debian requirements file
@ -183,6 +187,9 @@ def init(
"odoo/Dockerfile.j2",
odoo_version=odoo_version,
python_major_version=get_python_major_version(odoo_version),
python_minor_version_short=get_python_minor_version_short(
odoo_version
),
)
# Create 'src' folder that will contain all the odoo code

View File

@ -6,44 +6,42 @@ _ODOO_VERSION_TEMPLATES = [
{
"version": 8.0,
"python_major_version": "python2",
"python_libraries": [],
"python_minor_version_short": "py27",
},
{
"version": 9.0,
"python_major_version": "python2",
"python_libraries": ["openupgradelib==2.0.0"],
"python_minor_version_short": "py27",
},
{
"version": 10.0,
"python_major_version": "python2",
"python_libraries": ["openupgradelib==2.0.0"],
"python_minor_version_short": "py27",
},
{
"version": 11.0,
"python_major_version": "python3",
"python_libraries": ["openupgradelib==2.0.0"],
"python_minor_version_short": "py36",
},
{
"version": 12.0,
"python_major_version": "python3",
"python_libraries": [
"git+https://github.com/grap/openupgradelib.git"
"@2.0.1#egg=openupgradelib"
],
"python_minor_version_short": "py37",
},
{
"version": 13.0,
"python_major_version": "python3",
"python_libraries": ["openupgradelib"],
"python_minor_version_short": "py37",
},
{
"version": 14.0,
"python_major_version": "python3",
"python_libraries": ["openupgradelib"],
"python_minor_version_short": "py39",
},
{
"version": 15.0,
"python_major_version": "python3",
"python_minor_version_short": "py39",
"python_libraries": ["openupgradelib"],
},
]
@ -71,6 +69,12 @@ def get_python_major_version(version: float) -> str:
return get_version_template(version)["python_major_version"]
def get_python_minor_version_short(version: float) -> str:
"""Return the default minor python version (py27, py38) of Odoo for
a given version"""
return get_version_template(version)["python_minor_version_short"]
def get_version_options(mode: str) -> list:
"""Get options available for version click argument.
Arguments:
@ -88,10 +92,27 @@ def get_version_options(mode: str) -> list:
return version_options
def get_odoo_version_settings(
initial_version: float, final_version: float
) -> list:
"""Return a list of odoo version settings from the initial version to the final
version
"""
result = []
for version_template in _ODOO_VERSION_TEMPLATES:
if (
version_template["version"] >= initial_version
and version_template["version"] <= final_version
):
result.append(version_template)
return result
def get_odoo_versions(initial_version: float, final_version: float) -> list:
"""Return a list of odoo versions from the initial version to the final
version
"""
# TODO, call get_odoo_version_settings() and call keys()
result = []
for version_template in _ODOO_VERSION_TEMPLATES:
if (

View File

@ -12,6 +12,14 @@ odoo_versions:
- {{ odoo_version }}
{%- endfor %}
odoo_version_settings:
{%- for setting in odoo_version_settings %}
{{setting['version']}}:
python_minor_version_short: {{setting['python_minor_version_short']}}
{%- endfor %}
migration_steps:
{%- for step in steps %}
- name: {{ step['name'] }}

View File

@ -1,22 +1,17 @@
FROM odoo:{{ odoo_version }}
MAINTAINER GRAP, Coop It Easy
# Set User root for installations
USER root
# 1. Make available files in the containers
FROM ghcr.io/acsone/odoo-bedrock:{{ odoo_version }}-{{python_minor_version_short}}-latest
COPY ./src/odoo /odoo/src/odoo
COPY debian_requirements.txt /debian_requirements.txt
COPY python_requirements.txt /python_requirements.txt
# 2. Install extra debian packages
RUN apt-get update || true &&\
xargs apt-get install -y --no-install-recommends <debian_requirements.txt
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 {{ python_major_version }}\
-m pip install -r python_requirements.txt
# Reset to odoo user to run the container
USER odoo
RUN \
pip install --no-cache-dir \
-r /odoo/src/odoo/requirements.txt \
-f https://wheelhouse.acsone.eu/manylinux2014 \
&& pip install -r python_requirements.txt

View File

@ -1,5 +1,5 @@
{%- for python_librairy in python_libraries -%}
{{ python_librairy }}
{% endfor %}
odoorpc
openupgradelib
click-odoo

View File

@ -11,6 +11,14 @@ odoo_versions:
- 13.0
- 14.0
odoo_version_settings:
13.0:
python_minor_version_short: py37
14.0:
python_minor_version_short: py39
migration_steps:
- name: 1
version: 13.0