Skip to content

Commit e2e5c40

Browse files
committed
Add: Stop other containers
1 parent b489210 commit e2e5c40

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/deploy.yml

+28
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
npm install
6161
6262
IMAGE="kevinthedang/discord-ollama"
63+
REDIS="redis"
64+
OLLAMA="ollama/ollama"
6365
6466
if docker images | grep -q $IMAGE; then
6567
IMAGE_ID=$(docker images -q $IMAGE)
@@ -74,6 +76,32 @@ jobs:
7476
echo "Old $IMAGE Image Removed"
7577
fi
7678
79+
if docker images | grep -q $REDIS; then
80+
IMAGE_ID=$(docker images -q $REDIS)
81+
CONTAINER_IDS=$(docker ps -q --filter "ancestor=$IMAGE_ID")
82+
83+
if [ ! -z "$CONTAINER_IDS" ]; then
84+
# Stop and remove the running containers
85+
docker stop $CONTAINER_IDS
86+
echo "Stopped and removed the containers using the image $REDIS"
87+
fi
88+
docker rmi $IMAGE_ID
89+
echo "Old $REDIS Image Removed"
90+
fi
91+
92+
if docker images | grep -q $OLLAMA; then
93+
IMAGE_ID=$(docker images -q $OLLAMA)
94+
CONTAINER_IDS=$(docker ps -q --filter "ancestor=$IMAGE_ID")
95+
96+
if [ ! -z "$CONTAINER_IDS" ]; then
97+
# Stop and remove the running containers
98+
docker stop $CONTAINER_IDS
99+
echo "Stopped and removed the containers using the image $OLLAMA"
100+
fi
101+
docker rmi $IMAGE_ID
102+
echo "Old $OLLAMA Image Removed"
103+
fi
104+
77105
docker network prune -f
78106
docker system prune -a
79107

0 commit comments

Comments
 (0)