From 2f8ef46e75f9a85145279710d25b38c79d4a637f Mon Sep 17 00:00:00 2001 From: Bram Date: Mon, 8 Jun 2026 11:42:43 +0200 Subject: [PATCH] fix port extraction for node container --- Dockers/remote-node-container/entrypoint.sh | 28 ++++++++++++++++----- Dockers/remote-node-container/version | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Dockers/remote-node-container/entrypoint.sh b/Dockers/remote-node-container/entrypoint.sh index f8fec57..b21a500 100644 --- a/Dockers/remote-node-container/entrypoint.sh +++ b/Dockers/remote-node-container/entrypoint.sh @@ -15,6 +15,15 @@ extract_domain() { fi } +# Extract SSH port from Git URL (ssh://user@host:port/path format) +extract_port() { + local url=$1 + + if [[ $url == ssh://* ]] && [[ $url =~ ssh://[^@]+@[^:/]+:([0-9]+) ]]; then + echo "${BASH_REMATCH[1]}" + fi +} + # Check if the required environment variables are set if [ -z "$REPO_URL" ]; then echo "Error: REPO_URL environment variable must be set." @@ -237,15 +246,22 @@ fi # Ensure the SSH key has the correct permissions chmod 600 /root/.ssh/id_rsa -# Extract the domain from the REPO_URL +# Extract the domain and port from the REPO_URL DOMAIN=$(extract_domain "$REPO_URL") +PORT=$(extract_port "$REPO_URL") # Add the SSH configuration for the domain -echo "Host $DOMAIN - HostName $DOMAIN - IdentityFile /root/.ssh/id_rsa - StrictHostKeyChecking no -" >> /root/.ssh/config +{ + echo "Host $DOMAIN" + echo " HostName $DOMAIN" + echo " IdentityFile /root/.ssh/id_rsa" + echo " StrictHostKeyChecking no" + if [ -n "$PORT" ]; then + echo " Port $PORT" + fi +} >> /root/.ssh/config + +echo "Configured SSH for $DOMAIN${PORT:+ on port $PORT}" # Clone the repository if it doesn't exist if [ ! -d "/workspace/.git" ]; then diff --git a/Dockers/remote-node-container/version b/Dockers/remote-node-container/version index 6e63660..8336407 100644 --- a/Dockers/remote-node-container/version +++ b/Dockers/remote-node-container/version @@ -1 +1 @@ -5.0 \ No newline at end of file +5.1 \ No newline at end of file