fix port extraction for node container
Build and Push Docker Images / build-and-push (push) Successful in 3m39s

This commit is contained in:
2026-06-08 11:42:43 +02:00
parent 86360ec066
commit 2f8ef46e75
2 changed files with 23 additions and 7 deletions
+22 -6
View File
@@ -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