From e2bc176bb0335b9d906435233cee2bc093b20034 Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Thu, 6 Mar 2025 17:09:28 +0100 Subject: [PATCH] feat(image): addons git repos --- image/README.md | 11 ++++++++++- image/bin/git-clone-addons | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/image/README.md b/image/README.md index 12e718d9..472d5e84 100644 --- a/image/README.md +++ b/image/README.md @@ -240,11 +240,20 @@ Define the mail configuration with these env vars: The image can clone git repositories. * `GIT_SSH_PUBLIC_KEY` Public key for SSH connection. -* `GIT_SSH_PRIVATE_KEY` Base64 encoded private key for SSH connection. +* `GIT_SSH_PRIVATE_KEY` Base64 encoded private key for SSH connection: `cat ~/.ssh/id_ed2551 | base64 -w0` * `GITHUB_USERNAME` Username for git clone command with https. * `GITHUB_PERSONAL_ACCESS_TOKEN` Token for git clone command with https. * `ADDONS_GIT_REPOS` Comma seperated list of git clone urls appended with `#` and branch name. +You can use https and git urls for `ADDONS_GIT_REPOS`: + +```bash +ADDON_GIT_REPO=git@github.com:OCA/server-tools.git#16.0,git@github.com:Mint-System/Odoo-Apps-Server-Tools.gi#16.0 +ADDON_GIT_REPO=https://github.com/OCA/server-tools.git#16.0,https://github.com/Mint-System/Odoo-Apps-Server-Tools.gi#16.0 +``` + +If you use git url a valid SSH private/public key is required. + ### Addons Path The entrypoint script searches for module folders in the addons path and creates a new addons path. diff --git a/image/bin/git-clone-addons b/image/bin/git-clone-addons index a156f832..3434c917 100755 --- a/image/bin/git-clone-addons +++ b/image/bin/git-clone-addons @@ -30,10 +30,11 @@ if [ -n "$ADDONS_GIT_REPOS" ]; then GIT_PATH=$(parse-url "$GIT_URL" path | sed 's/.git//g') GIT_LOCAL_PATH="/var/lib/odoo/git/${GIT_HOSTNAME}/$GIT_PATH" + ssh-keyscan -t rsa,dsa "$GIT_HOSTNAME" > ~/.ssh/known_hosts 2>/dev/null + if [ ! -d "$GIT_LOCAL_PATH/.git" ]; then # Clone git repo and submodules mkdir -p "$GIT_LOCAL_PATH" - ssh-keyscan -t rsa,dsa "$GIT_HOSTNAME" > ~/.ssh/known_hosts 2>/dev/null if [ "${GIT_PROTO}${GIT_HOSTNAME}" = "https://github.com" ] && [ -n "$GITHUB_USERNAME" ]; then GIT_URL="${GIT_PROTO}${GITHUB_USERNAME}:${GITHUB_PERSONAL_ACCESS_TOKEN}@${GIT_HOSTNAME}/${GIT_PATH}.git"