Skip to content

Commit

Permalink
Merge pull request #132 from Code-Hammers/CHE-188/task/Update-Docker-…
Browse files Browse the repository at this point in the history
…Remove-All-Script

[CHE-188] Update Docker Remove All Script
  • Loading branch information
brok3turtl3 authored Jun 6, 2024
2 parents 75db4bd + 2428831 commit 7910943
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"docker-lint": "LINT_COMMAND=lint docker-compose -f docker-compose-lint.yml up --abort-on-container-exit",
"docker-lint:fix": "LINT_COMMAND=lint:fix docker-compose -f docker-compose-lint.yml up --abort-on-container-exit",
"docker-test:all": "docker-compose -f docker-compose-test.yml up --abort-on-container-exit",
"docker-remove-all": "bash ./scripts/docker-remove-all.sh ch ch-dev-dep-test cd-testv1 code-hammers",
"docker-remove-all": "bash ./scripts/docker-remove-all.sh ch ch-dev-dep code-hammers",
"docker-build-check": "bash ./scripts/build-check.sh",
"test:client": "cd client && npm test",
"test:all": "concurrently \"npm test\" \"npm run test:client\""
Expand Down
23 changes: 4 additions & 19 deletions scripts/docker-remove-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ echo ''

CONTAINER_SEARCH_NAME=$1
IMAGE_SEARCH_NAME_DEV=$2
IMAGE_SEARCH_NAME_TEST=$3
VOLUME_SEARCH_NAME=$4
VOLUME_SEARCH_NAME=$3

# Remove containers
echo -e "${CYAN}Removing existing containers from local environment:${NC}"
Expand All @@ -28,23 +27,9 @@ else
echo 'Removed containers.'
fi

# Remove dev images
# Remove images
echo -e "${CYAN}Removing existing dev images from local environment:${NC}"
IMAGES=$(docker images codehammers/$IMAGE_SEARCH_NAME_DEV -q)
REMOVEDIMAGES=0
if [ ! -z "$IMAGES" ]; then
docker rmi $IMAGES --force
REMOVEDIMAGES=1
fi
if [ "$REMOVEDIMAGES" = 1 ]; then
echo 'Removed images.'
else
echo 'No images to remove.'
fi

# Remove test images
echo -e "${CYAN}Removing existing dev images from local environment:${NC}"
IMAGES=$(docker images codehammers/$IMAGE_SEARCH_NAME_TEST -q)
IMAGES=$(docker images codehammers/$IMAGE_SEARCH_NAME_DEV* -q)
REMOVEDIMAGES=0
if [ ! -z "$IMAGES" ]; then
docker rmi $IMAGES --force
Expand All @@ -58,7 +43,7 @@ fi

# Remove volumes
echo -e "${CYAN}Removing existing volumes from local environment:${NC}"
VOLUMES=$(docker volume ls -q -f name=$VOLUME_SEARCH_NAME)
VOLUMES=$(docker volume ls -q -f name=$VOLUME_SEARCH_NAME*)
if [ ! -z "$VOLUMES" ]; then
docker volume rm $VOLUMES --force
echo 'Removed volumes.'
Expand Down

0 comments on commit 7910943

Please sign in to comment.