Skip to content

Commit

Permalink
Updates deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Jan 24, 2025
1 parent 20409a1 commit 29c43b4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,33 @@ replace_placeholders() {
echo "$template" | sed "s/{{CONTAINER_NAME}}/$container_name/g" | sed "s/{{CONTAINER_PORT}}/$container_port/g"
}

# Function to get the currently running image hash for a container
get_current_image_hash() {
local container_name=$1
ssh_blot "docker inspect --format='{{.Config.Image}}' $container_name 2>/dev/null | sed 's/.*://'" || echo ""
}

# Function to check if the container is already running with the desired hash
is_already_deployed() {
local container_name=$1
local current_hash=$(get_current_image_hash $container_name)
if [[ $current_hash == "$GIT_COMMIT_HASH" ]]; then
echo "$container_name is already running with the desired hash ($GIT_COMMIT_HASH). Skipping deployment."
return 0
fi
return 1
}

# Function to deploy a container
deploy_container() {
local container_name=$1
local container_port=$2

# Check if the container is already running with the desired hash
if is_already_deployed $container_name; then
return 0
fi

echo "Starting deployment for $container_name on port $container_port..."
remove_container_if_exists $container_name

Expand Down

0 comments on commit 29c43b4

Please sign in to comment.