Skip to content

Fixed teardown logic#194

Merged
sfreeman422 merged 1 commit intomasterfrom
fix/teardown
Mar 22, 2026
Merged

Fixed teardown logic#194
sfreeman422 merged 1 commit intomasterfrom
fix/teardown

Conversation

@sfreeman422
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 22, 2026 16:55
@sfreeman422 sfreeman422 merged commit aabacd0 into master Mar 22, 2026
2 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GitHub Actions deploy workflow teardown step to stop/remove existing containers before starting the updated service on the remote Linode host.

Changes:

  • Replaces the previous (incorrect) docker stop/rm targeting an image reference with commands that query containers by image ancestor.
  • Attempts to stop and remove all containers created from the deployment image prior to running the remote startup script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 59 to +63
docker pull "$IMAGE"

# Tear down the currently running container (if any).
docker stop ghcr.io/dev-chat/muzzle:latest 2>/dev/null || true
docker rm ghcr.io/dev-chat/muzzle:latest 2>/dev/null || true
# Tear down any running containers from this image.
docker stop $(docker ps -q --filter ancestor="$IMAGE") 2>/dev/null || true
docker rm $(docker ps -aq --filter ancestor="$IMAGE") 2>/dev/null || true
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker pull "$IMAGE" updates the local :latest tag before you query containers by --filter ancestor="$IMAGE". Since ancestor is resolved to an image ID, this can fail to match (and therefore not stop/remove) containers that were started from the previous :latest image. Consider capturing the container IDs to stop/remove before pulling, or stop/remove by a stable container name/label instead of the ancestor filter.

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +63
docker stop $(docker ps -q --filter ancestor="$IMAGE") 2>/dev/null || true
docker rm $(docker ps -aq --filter ancestor="$IMAGE") 2>/dev/null || true
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no matching containers, the command substitutions expand to empty and the runner executes docker stop / docker rm with no arguments (relying on || true). It would be cleaner and less noisy to guard on a non-empty container ID list (or use xargs -r) so Docker isn’t invoked with an empty argument list.

Suggested change
docker stop $(docker ps -q --filter ancestor="$IMAGE") 2>/dev/null || true
docker rm $(docker ps -aq --filter ancestor="$IMAGE") 2>/dev/null || true
CONTAINERS="$(docker ps -q --filter ancestor="$IMAGE")"
if [ -n "$CONTAINERS" ]; then
docker stop $CONTAINERS 2>/dev/null || true
fi
CONTAINERS_ALL="$(docker ps -aq --filter ancestor="$IMAGE")"
if [ -n "$CONTAINERS_ALL" ]; then
docker rm $CONTAINERS_ALL 2>/dev/null || true
fi

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants