mirror of
				https://github.com/odoocker/odoocker
				synced 2025-11-04 07:19:15 +01:00 
			
		
		
		
	upgrade: third party public and private addons are now dynamically cloned and extensible with a handy format
This commit is contained in:
		@@ -22,10 +22,14 @@ USE_S3=false
 | 
			
		||||
USE_SENTRY=false
 | 
			
		||||
USE_PGADMIN=false
 | 
			
		||||
 | 
			
		||||
# Enterprise
 | 
			
		||||
# GitHub user and access token to clone private repositories
 | 
			
		||||
GITHUB_USER=
 | 
			
		||||
GITHUB_ACCESS_TOKEN=
 | 
			
		||||
 | 
			
		||||
# GitHub user and access token to clone Enterprise repository
 | 
			
		||||
ENTERPRISE_USER=${GITHUB_USER}
 | 
			
		||||
ENTERPRISE_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN}
 | 
			
		||||
 | 
			
		||||
# Database
 | 
			
		||||
DB_HOST=postgres
 | 
			
		||||
DB_PORT=5432
 | 
			
		||||
 
 | 
			
		||||
@@ -7,9 +7,11 @@ services:
 | 
			
		||||
        - ODOO_TAG
 | 
			
		||||
        - ODOO_RC
 | 
			
		||||
        - ROOT_PATH
 | 
			
		||||
        - ENTERPRISE_USER
 | 
			
		||||
        - ENTERPRISE_ACCESS_TOKEN
 | 
			
		||||
        - ENTERPRISE_ADDONS
 | 
			
		||||
        - GITHUB_USER
 | 
			
		||||
        - GITHUB_ACCESS_TOKEN
 | 
			
		||||
        - ENTERPRISE_ADDONS
 | 
			
		||||
        - THIRD_PARTY_ADDONS
 | 
			
		||||
        - LOG_PATH
 | 
			
		||||
        - USE_REDIS
 | 
			
		||||
 
 | 
			
		||||
@@ -11,9 +11,11 @@ USER root
 | 
			
		||||
ARG ODOO_TAG
 | 
			
		||||
ARG ROOT_PATH
 | 
			
		||||
ARG LOG_PATH
 | 
			
		||||
ARG ENTERPRISE_USER
 | 
			
		||||
ARG ENTERPRISE_ACCESS_TOKEN
 | 
			
		||||
ARG ENTERPRISE_ADDONS
 | 
			
		||||
ARG GITHUB_USER
 | 
			
		||||
ARG GITHUB_ACCESS_TOKEN
 | 
			
		||||
ARG ENTERPRISE_ADDONS
 | 
			
		||||
ARG THIRD_PARTY_ADDONS
 | 
			
		||||
ARG ODOO_RC
 | 
			
		||||
ARG USE_REDIS
 | 
			
		||||
@@ -22,79 +24,79 @@ ARG USE_SENTRY
 | 
			
		||||
 | 
			
		||||
ENV ODOO_TAG=${ODOO_TAG} \
 | 
			
		||||
    LOG_PATH=${LOG_PATH} \
 | 
			
		||||
    ENTERPRISE_USER=${ENTERPRISE_USER} \
 | 
			
		||||
    ENTERPRISE_ACCESS_TOKEN=${ENTERPRISE_ACCESS_TOKEN} \
 | 
			
		||||
    ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \
 | 
			
		||||
    GITHUB_USER=${GITHUB_USER} \
 | 
			
		||||
    GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \
 | 
			
		||||
    ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \
 | 
			
		||||
    THIRD_PARTY_ADDONS=${THIRD_PARTY_ADDONS} \
 | 
			
		||||
    ODOO_RC=${ODOO_RC} \
 | 
			
		||||
    USE_REDIS=${USE_REDIS} \
 | 
			
		||||
    USE_S3=${USE_S3} \
 | 
			
		||||
    USE_SENTRY=${USE_SENTRY}
 | 
			
		||||
 | 
			
		||||
#---------------------#
 | 
			
		||||
#       Logging       #
 | 
			
		||||
#---------------------#
 | 
			
		||||
# Create odoo.log file
 | 
			
		||||
RUN touch ${LOG_PATH} && chown odoo:odoo ${LOG_PATH}
 | 
			
		||||
 | 
			
		||||
#------------------------#
 | 
			
		||||
#    APT Dependencies    #
 | 
			
		||||
#------------------------#
 | 
			
		||||
# Install Odoocker image dependencies
 | 
			
		||||
RUN apt-get update && apt-get install -y \
 | 
			
		||||
    apt-utils \
 | 
			
		||||
    # `zip` and `unzip` for filestore management
 | 
			
		||||
    zip \
 | 
			
		||||
    unzip \
 | 
			
		||||
    # `git` required packages
 | 
			
		||||
    git \
 | 
			
		||||
    git-man \
 | 
			
		||||
    less \
 | 
			
		||||
    libcbor0.8 \
 | 
			
		||||
    libcurl3-gnutls \
 | 
			
		||||
    libedit2 \
 | 
			
		||||
    liberror-perl \
 | 
			
		||||
    libfido2-1 \
 | 
			
		||||
    libxmuu1 \
 | 
			
		||||
    openssh-client \
 | 
			
		||||
    patch \
 | 
			
		||||
    xauth \
 | 
			
		||||
    # Clean up the apt cache to reduce the image size
 | 
			
		||||
    # Remove apt lists
 | 
			
		||||
    && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
#-----------------------#
 | 
			
		||||
#    Odoo Enterprise    #
 | 
			
		||||
#-----------------------#
 | 
			
		||||
# Create Enterprise addons directory
 | 
			
		||||
RUN mkdir -p ${ENTERPRISE_ADDONS} && chown odoo:odoo -R ${ENTERPRISE_ADDONS}
 | 
			
		||||
 | 
			
		||||
# Clone Enterprise addons if user and token are present
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/clone-enterprise.sh /
 | 
			
		||||
RUN /clone-enterprise.sh
 | 
			
		||||
 | 
			
		||||
#---------------------#
 | 
			
		||||
#   PIP Dependecies   #
 | 
			
		||||
#---------------------#
 | 
			
		||||
# Upgrade pip
 | 
			
		||||
RUN pip3 install --upgrade pip
 | 
			
		||||
 | 
			
		||||
# Copy & Install PIP requirements
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/requirements.txt /tmp/requirements.txt
 | 
			
		||||
 | 
			
		||||
RUN python3 -m pip install -r /tmp/requirements.txt && \
 | 
			
		||||
    rm /tmp/requirements.txt
 | 
			
		||||
 | 
			
		||||
#-----------------------#
 | 
			
		||||
#    Odoo Enterprise    #
 | 
			
		||||
#-----------------------#
 | 
			
		||||
 | 
			
		||||
# Create Enterprise addons directory
 | 
			
		||||
RUN mkdir -p ${ENTERPRISE_ADDONS} && \
 | 
			
		||||
    chown odoo:odoo -R ${ENTERPRISE_ADDONS}
 | 
			
		||||
 | 
			
		||||
# Clone Enterprise addons if user and token are present
 | 
			
		||||
RUN if [ -n "$GITHUB_USER" ] && [ -n "$GITHUB_ACCESS_TOKEN" ]; then \
 | 
			
		||||
        git clone https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@github.com/odoo/enterprise.git ${ENTERPRISE_ADDONS} --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags; \
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
#-------------------------#
 | 
			
		||||
#    Odoo Extra Addons    #
 | 
			
		||||
#-------------------------#
 | 
			
		||||
 | 
			
		||||
RUN mkdir -p ${THIRD_PARTY_ADDONS} && chown odoo:odoo -R ${THIRD_PARTY_ADDONS}
 | 
			
		||||
 | 
			
		||||
#--------------------------#
 | 
			
		||||
#    Third Party Addons    #
 | 
			
		||||
#--------------------------#
 | 
			
		||||
# Create third-party-addons directory and clone them
 | 
			
		||||
RUN mkdir -p ${THIRD_PARTY_ADDONS}
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/fix-manifest.py /
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/third-party-addons.sh /
 | 
			
		||||
RUN /third-party-addons.sh && chown odoo:odoo -R ${THIRD_PARTY_ADDONS}
 | 
			
		||||
 | 
			
		||||
#---------------------#
 | 
			
		||||
#       Logging       #
 | 
			
		||||
#---------------------#
 | 
			
		||||
 | 
			
		||||
# Create odoo.log file
 | 
			
		||||
RUN touch ${LOG_PATH} && chown odoo:odoo ${LOG_PATH}
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/clone-addons.sh /
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/third-party-addons.txt /
 | 
			
		||||
RUN /clone-addons.sh && chown odoo:odoo -R ${THIRD_PARTY_ADDONS}
 | 
			
		||||
 | 
			
		||||
#-----------------------#
 | 
			
		||||
#       Odoo Conf       #
 | 
			
		||||
#-----------------------#
 | 
			
		||||
 | 
			
		||||
# Copy environment variables & script to generate odoo.conf
 | 
			
		||||
COPY --chown=odoo:odoo ./.env /
 | 
			
		||||
COPY --chown=odoo:odoo ./odoo/odoo.conf /
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										70
									
								
								odoo/clone-addons.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										70
									
								
								odoo/clone-addons.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
# Function to clone and copy modules based on conditions
 | 
			
		||||
clone_and_copy_modules() {
 | 
			
		||||
    local repo_type=$1
 | 
			
		||||
    local repo_url=$2
 | 
			
		||||
    shift 2
 | 
			
		||||
    local modules_conditions=("$@")
 | 
			
		||||
 | 
			
		||||
    # Extract repo name from the URL
 | 
			
		||||
    repo_name=$(basename -s .git "$repo_url")
 | 
			
		||||
 | 
			
		||||
    # Determine the clone command based on repo type
 | 
			
		||||
    local clone_cmd
 | 
			
		||||
    if [[ $repo_type == "private" ]]; then
 | 
			
		||||
        clone_cmd="git clone https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@${repo_url#https://}"
 | 
			
		||||
    else
 | 
			
		||||
        clone_cmd="git clone $repo_url"
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    # Iterate over modules and conditions
 | 
			
		||||
    for (( i=0; i<${#modules_conditions[@]}; i+=2 )); do
 | 
			
		||||
        local module=${modules_conditions[i]}
 | 
			
		||||
        local condition=${modules_conditions[i+1]}
 | 
			
		||||
 | 
			
		||||
        # Check if the condition is true and clone and copy if needed
 | 
			
		||||
        if [[ $condition == true ]]; then
 | 
			
		||||
            # Clone the repository if not already cloned
 | 
			
		||||
            if [ ! -d "$repo_name" ]; then
 | 
			
		||||
                echo "Cloning $clone_cmd --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags"
 | 
			
		||||
                $clone_cmd --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags
 | 
			
		||||
            fi
 | 
			
		||||
            # Copy the module
 | 
			
		||||
            echo "Copying ${module} from ${repo_name} into ${THIRD_PARTY_ADDONS}"
 | 
			
		||||
            cp -r /${repo_name}/${module} ${THIRD_PARTY_ADDONS}/${module}
 | 
			
		||||
        fi
 | 
			
		||||
    done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Function to manually expand environment variables in a string
 | 
			
		||||
expand_env_vars() {
 | 
			
		||||
    while IFS=' ' read -r -a words; do
 | 
			
		||||
        for word in "${words[@]}"; do
 | 
			
		||||
            if [[ $word == \$* ]]; then
 | 
			
		||||
                varname=${word:2:-1} # Extract the variable name
 | 
			
		||||
                echo -n "${!varname} " # Substitute with its value
 | 
			
		||||
            else
 | 
			
		||||
                echo -n "$word "
 | 
			
		||||
            fi
 | 
			
		||||
        done
 | 
			
		||||
        echo
 | 
			
		||||
    done <<< "$1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Read the configuration file and process each line
 | 
			
		||||
while IFS= read -r line; do
 | 
			
		||||
    # Skip empty lines and lines starting with '#'
 | 
			
		||||
    if [[ -z "$line" || "$line" == \#* ]]; then
 | 
			
		||||
        continue
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    # Manually replace environment variables in the line with their values
 | 
			
		||||
    processed_line=$(expand_env_vars "$line")
 | 
			
		||||
    # Split the processed line into an array
 | 
			
		||||
    IFS=' ' read -r -a repo_info <<< "$processed_line"
 | 
			
		||||
    # Call the function with the repository type, URL, and modules with conditions
 | 
			
		||||
    clone_and_copy_modules "${repo_info[@]}"
 | 
			
		||||
done < "third-party-addons.txt"
 | 
			
		||||
							
								
								
									
										7
									
								
								odoo/clone-enterprise.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								odoo/clone-enterprise.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
if [ -n "$ENTERPRISE_USER" ] && [ -n "$ENTERPRISE_ACCESS_TOKEN" ]; then \
 | 
			
		||||
    git clone https://${ENTERPRISE_USER}:${ENTERPRISE_ACCESS_TOKEN}@github.com/odoo/enterprise.git ${ENTERPRISE_ADDONS} --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags
 | 
			
		||||
fi
 | 
			
		||||
@@ -1 +1 @@
 | 
			
		||||
Delete me once you add your first custom addon :)
 | 
			
		||||
Delete me once you add your first custom addon :)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								odoo/extra-addons/DELETE_ME.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								odoo/extra-addons/DELETE_ME.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
Delete me once you add your first extra addon :)
 | 
			
		||||
This folder is made for addons that are not clonable via GitHub.
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
    'name': 'Odoocker Base',
 | 
			
		||||
    'summary': 'Supercharge Odoo with Odoocker',
 | 
			
		||||
    'description': '''
 | 
			
		||||
        Some Odoocker dependencies require to some custom values that we cover with this Addon for you.
 | 
			
		||||
    ''',
 | 
			
		||||
    'version': '1.0.0',
 | 
			
		||||
    'category': 'Technical',
 | 
			
		||||
    'license': 'LGPL-3',
 | 
			
		||||
    'author': 'Odoocker',
 | 
			
		||||
    'maintainer': 'Odoocker',
 | 
			
		||||
    'contributors': [
 | 
			
		||||
        'Yhael S <yhaelopez@gmail.com>'
 | 
			
		||||
    ],
 | 
			
		||||
    'depends': [
 | 
			
		||||
        'base'
 | 
			
		||||
    ],
 | 
			
		||||
    'data': [
 | 
			
		||||
        'data/ir_config_parameter.xml'
 | 
			
		||||
    ],
 | 
			
		||||
    'application': False,
 | 
			
		||||
    'installable': True,
 | 
			
		||||
    'auto_install': True
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<odoo>
 | 
			
		||||
    <!-- When initializing Odoo through Docker this parameter is missing. -->
 | 
			
		||||
    <record id="report_url" model="ir.config_parameter">
 | 
			
		||||
        <field name="key">report.url</field>
 | 
			
		||||
        <field name="value">http://127.0.0.1:8069</field>
 | 
			
		||||
    </record>
 | 
			
		||||
 | 
			
		||||
    <!-- When initializing Odoo with S3 storage. -->
 | 
			
		||||
    <record id="ir_attachment_location" model="ir.config_parameter">
 | 
			
		||||
        <field name="key">ir_attachment.location</field>
 | 
			
		||||
        <field name="value">s3</field>
 | 
			
		||||
    </record>
 | 
			
		||||
</odoo>
 | 
			
		||||
@@ -2,5 +2,4 @@ debugpy
 | 
			
		||||
websocket-client
 | 
			
		||||
redis
 | 
			
		||||
boto3
 | 
			
		||||
sentry-sdk
 | 
			
		||||
urllib3==1.26.5 # Odoo community is currently locked in this version
 | 
			
		||||
sentry-sdk==1.9.0 # Fixed because Odoo depends on urllib3==1.26.5
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
# Check if the repository directory exists and either Redis or S3 is to be used
 | 
			
		||||
if [[ ${USE_REDIS} == "true" || ${USE_S3} == "true" ]]; then
 | 
			
		||||
    git clone https://github.com/odoocker/odoo-cloud-platform.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags;
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ ${USE_REDIS} == "true" ]]; then
 | 
			
		||||
    cp -r odoo-cloud-platform/session_redis ${THIRD_PARTY_ADDONS}/session_redis
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Check the USE_S3 variable to decide whether to copy S3 directories
 | 
			
		||||
if [[ ${USE_S3} == "true" ]]; then
 | 
			
		||||
    cp -r odoo-cloud-platform/base_attachment_object_storage ${THIRD_PARTY_ADDONS}/base_attachment_object_storage
 | 
			
		||||
    cp -r odoo-cloud-platform/attachment_s3 ${THIRD_PARTY_ADDONS}/attachment_s3
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Check if the repository directory exists and Sentry is to be used
 | 
			
		||||
if [[ ${USE_SENTRY} == "true" ]]; then
 | 
			
		||||
    git clone https://github.com/odoocker/server-tools.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags;
 | 
			
		||||
    cp -r server-tools/sentry ${THIRD_PARTY_ADDONS}/sentry
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										13
									
								
								odoo/third-party-addons.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								odoo/third-party-addons.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
# This file is read by clone-addons.sh
 | 
			
		||||
 | 
			
		||||
# Odoocker repositories
 | 
			
		||||
public https://github.com/odoocker/odoocker-modules.git odoocker_base true
 | 
			
		||||
public https://github.com/odoocker/odoo-cloud-platform.git session_redis ${USE_REDIS} base_attachment_object_storage ${USE_S3} attachment_s3 ${USE_S3}
 | 
			
		||||
public https://github.com/odoocker/server-tools.git sentry ${USE_SENTRY}
 | 
			
		||||
 | 
			
		||||
# Add repositories with the following format:
 | 
			
		||||
# <public|private> <repo_url> <module1> <copy_module1_condition> <module2> <copy_module2_condition> ...
 | 
			
		||||
 | 
			
		||||
# Public repositories
 | 
			
		||||
 | 
			
		||||
# Private repositories
 | 
			
		||||
		Reference in New Issue
	
	Block a user