mirror of
https://github.com/odoocker/odoocker
synced 2025-11-04 23:29:19 +01:00
refactored enterprise + third party addons clonning process
This commit is contained in:
@@ -65,16 +65,6 @@ RUN apt-get update && apt-get install -y \
|
|||||||
# Remove apt lists
|
# Remove apt lists
|
||||||
&& rm -rf /var/lib/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 #
|
# PIP Dependecies #
|
||||||
#---------------------#
|
#---------------------#
|
||||||
@@ -84,15 +74,15 @@ COPY --chown=odoo:odoo ./odoo/requirements.txt /tmp/requirements.txt
|
|||||||
RUN python3 -m pip install -r /tmp/requirements.txt && \
|
RUN python3 -m pip install -r /tmp/requirements.txt && \
|
||||||
rm /tmp/requirements.txt
|
rm /tmp/requirements.txt
|
||||||
|
|
||||||
#--------------------------#
|
#--------------------------------------------#
|
||||||
# Third Party Addons #
|
# Odoo Enterprise + Third Party Addons #
|
||||||
#--------------------------#
|
#--------------------------------------------#
|
||||||
# Create third-party-addons directory and clone them
|
# Create third-party-addons directory and clone them
|
||||||
RUN mkdir -p ${THIRD_PARTY_ADDONS}
|
RUN mkdir -p ${THIRD_PARTY_ADDONS}
|
||||||
COPY --chown=odoo:odoo ./odoo/fix-manifest.py /
|
|
||||||
COPY --chown=odoo:odoo ./odoo/clone-addons.sh /
|
COPY --chown=odoo:odoo ./odoo/clone-addons.sh /
|
||||||
COPY --chown=odoo:odoo ./odoo/third-party-addons.txt /
|
COPY --chown=odoo:odoo ./odoo/third-party-addons.txt /
|
||||||
RUN /clone-addons.sh && chown odoo:odoo -R ${THIRD_PARTY_ADDONS}
|
# RUN /clone-addons.sh && chown odoo:odoo -R ${THIRD_PARTY_ADDONS}
|
||||||
|
RUN /clone-addons.sh
|
||||||
|
|
||||||
#-----------------------#
|
#-----------------------#
|
||||||
# Odoo Conf #
|
# Odoo Conf #
|
||||||
|
|||||||
@@ -2,50 +2,81 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Function to construct the clone command
|
||||||
|
construct_clone_command() {
|
||||||
|
local repo_type=$1
|
||||||
|
local repo_url=$2
|
||||||
|
case $repo_type in
|
||||||
|
private) echo "git clone https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@${repo_url#https://}" ;;
|
||||||
|
enterprise)
|
||||||
|
[ -n "$ENTERPRISE_USER" ] && [ -n "$ENTERPRISE_ACCESS_TOKEN" ] && \
|
||||||
|
echo "git clone https://${ENTERPRISE_USER}:${ENTERPRISE_ACCESS_TOKEN}@${repo_url#https://} ${ENTERPRISE_ADDONS}"
|
||||||
|
;;
|
||||||
|
*) echo "git clone $repo_url" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Function to clone and copy modules based on conditions
|
# Function to clone and copy modules based on conditions
|
||||||
clone_and_copy_modules() {
|
clone_and_copy_modules() {
|
||||||
local repo_type=$1
|
local repo_type=$1
|
||||||
local repo_url=$2
|
local repo_url=$2
|
||||||
|
local clone_cmd=$(construct_clone_command $repo_type $repo_url)
|
||||||
|
local repo_name=$(basename -s .git "$repo_url")
|
||||||
|
|
||||||
shift 2
|
shift 2
|
||||||
local modules_conditions=("$@")
|
local modules_conditions=("$@")
|
||||||
|
|
||||||
# Extract repo name from the URL
|
# Clone and copy logic for enterprise repository
|
||||||
repo_name=$(basename -s .git "$repo_url")
|
if [[ $repo_type == "enterprise" ]]; then
|
||||||
|
if [[ ! -d "${ENTERPRISE_ADDONS}" ]] && [ -n "$GITHUB_USER" ] && [ -n "$GITHUB_ACCESS_TOKEN" ]; then
|
||||||
# Determine the clone command based on repo type
|
$clone_cmd --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags
|
||||||
local clone_cmd
|
fi
|
||||||
if [[ $repo_type == "private" ]]; then
|
|
||||||
clone_cmd="git clone https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@${repo_url#https://}"
|
|
||||||
else
|
else
|
||||||
clone_cmd="git clone $repo_url"
|
# Determine if any module has a true condition
|
||||||
|
local should_clone=false
|
||||||
|
if [[ ${#modules_conditions[@]} -eq 1 ]]; then
|
||||||
|
[[ ${modules_conditions[0]} == true ]] && should_clone=true
|
||||||
|
else
|
||||||
|
for (( i=1; i<${#modules_conditions[@]}; i+=2 )); do
|
||||||
|
if [[ ${modules_conditions[i]} == true ]]; then
|
||||||
|
should_clone=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Iterate over modules and conditions
|
# Clone the repo if should_clone is true and it's not already cloned
|
||||||
|
if [[ $should_clone == true && ! -d "$repo_name" ]]; then
|
||||||
|
$clone_cmd --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the modules if the condition is true
|
||||||
|
if [[ $should_clone == true ]]; then
|
||||||
for (( i=0; i<${#modules_conditions[@]}; i+=2 )); do
|
for (( i=0; i<${#modules_conditions[@]}; i+=2 )); do
|
||||||
local module=${modules_conditions[i]}
|
local module=${modules_conditions[i]}
|
||||||
local condition=${modules_conditions[i+1]}
|
local condition=${modules_conditions[i+1]}
|
||||||
|
|
||||||
# Check if the condition is true and clone and copy if needed
|
|
||||||
if [[ $condition == true ]]; then
|
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}"
|
echo "Copying ${module} from ${repo_name} into ${THIRD_PARTY_ADDONS}"
|
||||||
cp -r /${repo_name}/${module} ${THIRD_PARTY_ADDONS}/${module}
|
cp -r /${repo_name}/${module} ${THIRD_PARTY_ADDONS}/${module}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to manually expand environment variables in a string
|
# Function to manually expand environment variables in a string
|
||||||
expand_env_vars() {
|
expand_env_vars() {
|
||||||
while IFS=' ' read -r -a words; do
|
while IFS=' ' read -r -a words; do
|
||||||
for word in "${words[@]}"; do
|
for word in "${words[@]}"; do
|
||||||
if [[ $word == \$* ]]; then
|
if [[ $word == \$\{* ]]; then
|
||||||
varname=${word:2:-1} # Extract the variable name
|
# Remove the leading '${' and the trailing '}' from the word
|
||||||
|
varname=${word:2:-1}
|
||||||
|
# Check if the variable is set and not empty
|
||||||
|
if [ -n "${!varname+x}" ]; then
|
||||||
echo -n "${!varname} " # Substitute with its value
|
echo -n "${!varname} " # Substitute with its value
|
||||||
|
else
|
||||||
|
echo -n "false " # Default to false if not set
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -n "$word "
|
echo -n "$word "
|
||||||
fi
|
fi
|
||||||
@@ -56,15 +87,6 @@ expand_env_vars() {
|
|||||||
|
|
||||||
# Read the configuration file and process each line
|
# Read the configuration file and process each line
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
# Skip empty lines and lines starting with '#'
|
[[ -z "$line" || "$line" == \#* ]] && continue
|
||||||
if [[ -z "$line" || "$line" == \#* ]]; then
|
clone_and_copy_modules $(expand_env_vars "$line")
|
||||||
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"
|
done < "third-party-addons.txt"
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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,34 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
# Define the path to the manifest file
|
|
||||||
manifest_file_path = sys.argv[1]
|
|
||||||
|
|
||||||
# Read the file content
|
|
||||||
with open(manifest_file_path, 'r') as file:
|
|
||||||
lines = file.readlines()
|
|
||||||
|
|
||||||
# Find the start and end index of the manifest dictionary
|
|
||||||
start_index = next(i for i, line in enumerate(lines) if line.strip().startswith('{'))
|
|
||||||
end_index = next(i for i, line in enumerate(lines) if line.strip().endswith('}'))
|
|
||||||
|
|
||||||
# Construct and evaluate the manifest dictionary
|
|
||||||
manifest_dict = eval(''.join(lines[start_index:end_index + 1]))
|
|
||||||
|
|
||||||
# Modify the manifest dictionary
|
|
||||||
manifest_dict['installable'] = True
|
|
||||||
manifest_dict['auto_install'] = True
|
|
||||||
|
|
||||||
# Construct the modified manifest string
|
|
||||||
modified_manifest_lines = ['{\n']
|
|
||||||
for key, value in manifest_dict.items():
|
|
||||||
modified_manifest_lines.append(f" '{key}': {repr(value)},\n")
|
|
||||||
modified_manifest_lines.append('}\n')
|
|
||||||
|
|
||||||
# Replace the manifest dictionary string in the content
|
|
||||||
lines[start_index:end_index + 1] = modified_manifest_lines
|
|
||||||
|
|
||||||
# Write the modified content back to the file
|
|
||||||
with open(manifest_file_path, 'w') as file:
|
|
||||||
file.writelines(lines)
|
|
||||||
|
|
||||||
print(f"Modified {manifest_file_path}")
|
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
# This file is read by clone-addons.sh
|
# This file is read by clone-addons.sh
|
||||||
|
|
||||||
|
# Enterprise addons
|
||||||
|
enterprise https://github.com/odoo/enterprise true
|
||||||
|
|
||||||
# Odoocker repositories
|
# Odoocker repositories
|
||||||
public https://github.com/odoocker/odoocker-modules.git odoocker_base true
|
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/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}
|
public https://github.com/odoocker/server-tools.git sentry ${USE_SENTRY}
|
||||||
|
|
||||||
# Add repositories with the following format:
|
# Add repositories with the following format:
|
||||||
# <public|private> <repo_url> <module1> <copy_module1_condition> <module2> <copy_module2_condition> ...
|
# <public|private> <repo_url> <true|false>
|
||||||
|
# or
|
||||||
|
# <public|private> <repo_url> <module1> <true|false> <module2> <true|false> ...
|
||||||
|
|
||||||
# Public repositories
|
# Public repositories
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user