Conversation
There was a problem hiding this comment.
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/rmtargeting 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.
| 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 |
There was a problem hiding this comment.
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.
| docker stop $(docker ps -q --filter ancestor="$IMAGE") 2>/dev/null || true | ||
| docker rm $(docker ps -aq --filter ancestor="$IMAGE") 2>/dev/null || true |
There was a problem hiding this comment.
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.
| 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 |
No description provided.