Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHE-188] Update Docker Remove All Script #132

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
seantokuzo marked this conversation as resolved.
Show resolved Hide resolved
"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
Loading