Skip to content
Extraits de code Groupes Projets
Valider 58344464 rédigé par Théo - Le Filament's avatar Théo - Le Filament
Parcourir les fichiers

feat(build): script to retrieve addons and save commit hashes (backported from 16.0)

parent 4224a2ef
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
FROM python:3.10-slim-bullseye AS builder FROM python:3.10-slim-bullseye AS builder
RUN set -x; \ RUN set -x; \
apt-get update &&\ apt-get update \
apt-get install -y --no-install-recommends build-essential libldap2-dev libpq-dev libsasl2-dev &&\ && apt-get install --yes --no-install-recommends build-essential libldap2-dev libpq-dev libsasl2-dev \
pip install wheel &&\ && pip install 'wheel' \
pip wheel --wheel-dir=/svc/wheels -r https://raw.githubusercontent.com/oca/OCB/15.0/requirements.txt &&\ && pip wheel --wheel-dir=/svc/wheels --requirement 'https://raw.githubusercontent.com/oca/OCB/15.0/requirements.txt' \
pip wheel --wheel-dir=/svc/wheels phonenumbers simplejson openupgradelib PyYAML && pip wheel --wheel-dir=/svc/wheels 'phonenumbers' 'simplejson' 'openupgradelib' 'PyYAML'
FROM python:3.10-slim-bullseye AS final FROM python:3.10-slim-bullseye AS final
...@@ -13,102 +13,107 @@ ENV LANG=C.UTF-8 \ ...@@ -13,102 +13,107 @@ ENV LANG=C.UTF-8 \
PGDATABASE=odoo PGDATABASE=odoo
RUN set -x; \ RUN set -x; \
apt-get update &&\ apt-get update \
apt-get install -y --no-install-recommends \ && apt-get install --yes --no-install-recommends \
curl \ curl \
git \ git \
gnupg \ gnupg \
openssh-client \ openssh-client \
xmlsec1 &&\ xmlsec1 \
echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' >> /etc/apt/sources.list.d/postgresql.list &&\ && echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' >> /etc/apt/sources.list.d/postgresql.list \
curl -SL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - &&\ && curl -SL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
curl -o wkhtmltox.deb -SL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.bullseye_amd64.deb &&\ && curl -o wkhtmltox.deb -SL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.bullseye_amd64.deb \
echo 'cecbf5a6abbd68d324a7cd6c51ec843d71e98951 wkhtmltox.deb' | sha1sum -c - &&\ && echo 'cecbf5a6abbd68d324a7cd6c51ec843d71e98951 wkhtmltox.deb' | sha1sum -c - \
apt-get update &&\ && apt-get update \
apt-get install -y --no-install-recommends ./wkhtmltox.deb &&\ && apt-get install -y --no-install-recommends ./wkhtmltox.deb \
apt-get install -y --no-install-recommends postgresql-client &&\ && apt-get install -y --no-install-recommends postgresql-client \
apt-get -y autoremove &&\ && apt-get -y autoremove \
rm -rf /var/lib/apt/lists/* wkhtmltox.deb && rm -rf /var/lib/apt/lists/* wkhtmltox.deb
COPY --from=builder /svc /svc COPY --from=builder /svc /svc
RUN pip3 install --no-index --find-links=/svc/wheels -r https://raw.githubusercontent.com/oca/OCB/15.0/requirements.txt &&\ RUN pip3 install --no-index --find-links=/svc/wheels --requirement 'https://raw.githubusercontent.com/oca/OCB/15.0/requirements.txt' \
pip3 install --no-index --find-links=/svc/wheels phonenumbers simplejson openupgradelib PyYAML && pip3 install --no-index --find-links=/svc/wheels 'phonenumbers' 'simplejson' 'openupgradelib' 'PyYAML'
ARG SAVE_COMMITS_DIR='/opt/odoo_commits/'
ENV SAVE_COMMITS_DIR=$SAVE_COMMITS_DIR
# Add Git Known Hosts # Add Git Known Hosts
COPY ./ssh_known_git_hosts /root/.ssh/known_hosts COPY ./ssh_known_git_hosts /root/.ssh/known_hosts
# Install Odoo and remove not French translations and .git directory to limit amount of data used by container # Install Odoo and remove not French translations and .git directory to limit amount of data used by container
ARG SAVE_COMMITS_FILENAME='ocb'
RUN set -x; \ RUN set -x; \
useradd --create-home --home-dir /opt/odoo --no-log-init odoo &&\ repo='https://github.com/OCA/OCB' \
/bin/bash -c "mkdir -p /opt/odoo/{etc,odoo,additional_addons,private_addons,data,private}" &&\ branch='15.0' \
curl -L https://github.com/OCA/OCB/tarball/15.0 | tar -xzC /opt/odoo/odoo --strip-components 1 &&\ && useradd --create-home --home-dir /opt/odoo --no-log-init odoo \
find /opt/odoo/odoo/addons/*/i18n/ /opt/odoo/odoo/odoo/addons/base/i18n/ -type f -not -name 'fr.po' -delete &&\ && /bin/bash -c "mkdir -p /opt/odoo/{etc,odoo,additional_addons,private_addons,data,private}" \
chown -R odoo:odoo /opt/odoo && mkdir /opt/odoo_commits \
&& git clone --single-branch --branch "${branch}" --depth 1 "${repo}" /tmp/repo \
&& commit="$(git -C /tmp/repo rev-parse HEAD)" \
&& mv /tmp/repo/* /opt/odoo/odoo/ \
&& echo "${repo};${commit}" > $SAVE_COMMITS_DIR/$SAVE_COMMITS_FILENAME \
&& rm -r /tmp/repo \
# Only keep French translations.
&& find /opt/odoo/odoo/addons/*/i18n/ /opt/odoo/odoo/odoo/addons/base/i18n/ -type f -not -name 'fr.po' -delete \
&& echo "info: OCB commit:" \
&& cat $SAVE_COMMITS_DIR/$SAVE_COMMITS_FILENAME
# Add script to download Odoo addons.
COPY --chown=root:root --chmod=755 ./get_addons /usr/local/bin
# Install Odoo OCA default dependencies - Commented modules do not exist yet # Install Odoo OCA default dependencies - Commented modules do not exist yet
RUN set -x; \ RUN set -x; \
mkdir -p /tmp/oca-repos/ &&\ get_addons 'https://github.com/OCA/account-financial-reporting' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/account-financial-reporting/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="account-financial-reporting" --strip-components 1 &&\ account_tax_balance \
mv /tmp/oca-repos/account-financial-reporting/account_tax_balance /opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/account-financial-tools' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/account-financial-tools/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="account-financial-tools" --strip-components 1 &&\ account_lock_date_update \
mv /tmp/oca-repos/account-financial-tools/account_lock_date_update \ account_move_name_sequence \
/tmp/oca-repos/account-financial-tools/account_move_name_sequence \ && get_addons 'https://github.com/OCA/account-invoicing' '15.0' 'additional_addons' \
/opt/odoo/additional_addons/ &&\ sale_timesheet_invoice_description \
curl -L https://github.com/OCA/account-invoicing/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="account-invoicing" --strip-components 1 &&\ && get_addons 'https://github.com/OCA/account-reconcile' '15.0' 'additional_addons' \
mv /tmp/oca-repos/account-invoicing/sale_timesheet_invoice_description \ account_reconciliation_widget \
/opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/bank-statement-import' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/account-reconcile/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="account-reconcile" --strip-components 1 &&\ account_statement_import \
mv /tmp/oca-repos/account-reconcile/account_reconciliation_widget \ && get_addons 'https://github.com/OCA/crm' '15.0' 'additional_addons' \
/opt/odoo/additional_addons/ &&\ crm_stage_probability \
curl -L https://github.com/OCA/bank-statement-import/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="bank-statement-import" --strip-components 1 &&\ && get_addons 'https://github.com/OCA/partner-contact' '15.0' 'additional_addons' \
mv /tmp/oca-repos/bank-statement-import/account_statement_import \ partner_firstname \
/opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/project' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/crm/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="crm" --strip-components 1 &&\ project_status \
mv /tmp/oca-repos/crm/crm_stage_probability /opt/odoo/additional_addons/ &&\ project_task_default_stage \
curl -L https://github.com/OCA/partner-contact/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="partner-contact" --strip-components 1 &&\ project_template \
mv /tmp/oca-repos/partner-contact/partner_firstname \ project_timeline \
/opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/server-brand' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/project/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="project" --strip-components 1 &&\ disable_odoo_online \
mv /tmp/oca-repos/project/project_status \ remove_odoo_enterprise \
/tmp/oca-repos/project/project_task_default_stage \ && get_addons 'https://github.com/OCA/server-tools' '15.0' 'additional_addons' \
/tmp/oca-repos/project/project_template \ base_search_fuzzy \
/tmp/oca-repos/project/project_timeline \ module_change_auto_install \
/opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/server-ux' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/server-brand/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="server-brand" --strip-components 1 &&\ base_technical_features \
mv /tmp/oca-repos/server-brand/disable_odoo_online \ date_range \
/tmp/oca-repos/server-brand/remove_odoo_enterprise \ mass_editing \
/opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/social' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/server-tools/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="server-tools" --strip-components 1 &&\ base_search_mail_content \
mv /tmp/oca-repos/server-tools/base_search_fuzzy \ mail_debrand \
/tmp/oca-repos/server-tools/module_change_auto_install \ mail_tracking \
/opt/odoo/additional_addons/ &&\ && get_addons 'https://github.com/OCA/web' '15.0' 'additional_addons' \
curl -L https://github.com/OCA/server-ux/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="server-ux" --strip-components 1 &&\ web_environment_ribbon \
mv /tmp/oca-repos/server-ux/base_technical_features \ web_responsive \
/tmp/oca-repos/server-ux/date_range \ web_no_bubble \
/tmp/oca-repos/server-ux/mass_editing \ web_timeline \
/opt/odoo/additional_addons/ &&\ # Only keep French translations.
curl -L https://github.com/OCA/social/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="social" --strip-components 1 &&\ && find /opt/odoo/additional_addons/*/i18n/ -type f -not -name 'fr.po' -delete \
mv /tmp/oca-repos/social/base_search_mail_content \ # Install Le Filament default addons.
/tmp/oca-repos/social/mail_debrand \ && get_addons 'https://sources.le-filament.com/lefilament/remove_login_links.git' '15.0' 'private_addons/remove_login_links' \
/tmp/oca-repos/social/mail_tracking \ && get_addons 'https://sources.le-filament.com/lefilament/lefilament_release_agent.git' '15.0' 'private_addons/lefilament_release_agent' \
/opt/odoo/additional_addons/ &&\ && echo "info: default addon commits:" \
curl -L https://github.com/OCA/web/tarball/15.0 | tar -xzC /tmp/oca-repos/ --one-top-level="web" --strip-components 1 &&\ && cat $SAVE_COMMITS_DIR/$SAVE_COMMITS_FILENAME
mv /tmp/oca-repos/web/web_environment_ribbon \
/tmp/oca-repos/web/web_responsive \
/tmp/oca-repos/web/web_no_bubble \
/tmp/oca-repos/web/web_timeline \
/opt/odoo/additional_addons/ &&\
rm -rf /tmp/oca-repos/ &&\
find /opt/odoo/additional_addons/*/i18n/ -type f -not -name 'fr.po' -delete &&\
# Install Le Filament default dependency
git clone -b 15.0 --depth 1 https://sources.le-filament.com/lefilament/remove_login_links.git /opt/odoo/private_addons/remove_login_links &&\
git clone -b 15.0 --depth 1 https://sources.le-filament.com/lefilament/lefilament_release_agent.git /opt/odoo/private_addons/lefilament_release_agent &&\
chown -R odoo:odoo /opt/odoo
# Copy entrypoint script and Odoo configuration file # Copy entrypoint script and Odoo configuration file
COPY ./entrypoint.sh / COPY ./entrypoint.sh /
COPY ./odoo.conf /opt/odoo/etc/odoo.conf COPY ./odoo.conf /opt/odoo/etc/odoo.conf
RUN chown odoo:odoo /opt/odoo/etc/odoo.conf RUN chown -R odoo:odoo /opt/odoo
# Mount /opt/odoo/data to allow restoring filestore # Mount /opt/odoo/data to allow restoring filestore
VOLUME ["/opt/odoo/data/"] VOLUME ["/opt/odoo/data/"]
......
#!/bin/sh
set -e
ODOO_ROOT_DIR=${ODOO_ROOT_DIR:-'/opt/odoo'}
SAVE_COMMITS_DIR=${SAVE_COMMITS_DIR:-'/opt/odoo_commits'}
SAVE_COMMITS_FILENAME=${SAVE_COMMITS_FILENAME:-'custom_addons'}
save_commit() {
repo="$1"
commit="$2"
module="$3"
dst="$4"
echo "${repo};${commit};${module};${dst}" >> "${SAVE_COMMITS_DIR}/${SAVE_COMMITS_FILENAME}"
}
repo="$1"
shift
ref="$1"
shift
dst="$1"
shift
modules="$@"
git clone --filter=tree:0 "${repo}" /tmp/repo
git -C /tmp/repo checkout "${ref}"
commit="$(git -C /tmp/repo rev-parse HEAD)"
if [ -n "$modules" ]; then
for module in $modules; do
mv "/tmp/repo/${module}" "${ODOO_ROOT_DIR}/${dst}/"
save_commit "$repo" "$commit" "$module" "$dst"
done
else
module="$(basename $dst)"
mkdir -p "/${ODOO_ROOT_DIR}/${dst}"
mv /tmp/repo/* "${ODOO_ROOT_DIR}/${dst}/"
save_commit "$repo" "$commit" "$module" "$dst"
fi
rm -r /tmp/repo
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter