Skip to content

Commit 1d86c12

Browse files
authored
Merge pull request #673 from Survey845/issue-474
Issue-#474 Clean Makefile
2 parents d5e6dab + 96296c5 commit 1d86c12

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

Makefile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
# - all (default): Builds all targets and runs all tests/checks
1010
# - clean: Cleans the docker containers.
1111
# - check: Setup as master node, and runs all tests/checks, will be triggered by CI
12-
# - deep-clean: Clean up all docker images and local storage.
13-
# - doc: Start a local web service to explore the documentation
12+
# - deep-clean: Clean up all docker images and local storage.
13+
# - doc: Start a local web service to explore the documentation
1414
# - docker[-clean]: Build/clean docker images locally
1515
# - docker-compose: Start development docker-compose.
16-
# - license: Checks sourrce files for Apache license header
17-
# - local: Run all services ad-hoc
1816
# - help: Output the help instructions for each command
17+
# - license: Checks source files for Apache license header
18+
# - local: Run all services ad-hoc
1919
# - reset: Clean up and remove local storage (only use for development)
2020
# - restart: Stop the cello service and then start
2121
# - setup-master: Setup the host as a master node, install pkg and download docker images
@@ -132,25 +132,21 @@ all: check
132132

133133
clean: ##@Clean Stop services and clean docker containers.
134134
make stop
135-
if docker ps -a | grep "cello-"; then \
136-
docker ps -a | grep "cello-" | awk '{print $1}' | xargs docker rm -f >/dev/null 2>&1; \
137-
fi
138-
135+
@-docker ps -a --filter "name=cello-" --format "{{.ID}}" | xargs docker rm -f >/dev/null 2>&1
136+
@echo "Cleared out containers"
137+
139138
check: ##@Code Check code format
140139
@$(MAKE) license
141140
find ./docs -type f -name "*.md" -exec egrep -l " +$$" {} \;
142141
cd src/api-engine && tox && cd ${ROOT_PATH}
143142
make docker-compose
144143
MODE=dev make start
145144
sleep 10
146-
# make test-api
147145
MODE=dev make stop
148146
make check-dashboard
149147

150148
deep-clean: ##@Clean Stop services, clean docker images and remove mounted local storage.
151-
make stop
152-
make clean
153-
make clean-docker-images
149+
make clean-images
154150
rm -rf $(LOCAL_STORAGE_PATH)
155151

156152
doc: ##@Documentation Build local online documentation and start serve
@@ -159,21 +155,20 @@ doc: ##@Documentation Build local online documentation and start serve
159155

160156
docker: images ##@Build Build all required docker images locally
161157

162-
docker-clean:##@Clean Clean docker images locally
163-
make stop
158+
docker-clean:##@Clean Clean docker images locally
164159
make clean-images
165160

166161
docker-compose: api-engine fabric docker-rest-agent dashboard ##@Development Start development docker-compose
167162

163+
help: ##@Help Show this help.
164+
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
165+
168166
license: ##@Code Check source files for Apache license header
169167
scripts/check_license.sh
170168

171169
local:##@Development Run all services ad-hoc
172170
make docker-compose start-docker-compose
173171

174-
help: ##@Help Show this help.
175-
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
176-
177172
reset:##@Development Clean up and remove local storage (only use for development)
178173
make clean
179174
echo "Clean up and remove all local storage..."
@@ -191,17 +186,21 @@ start: ##@Service Start service
191186
make start-docker-compose
192187

193188
stop: ##@Service Stop service
194-
if [ "$(CONFIG_DOCKER_COMPOSE_DEPLOY)" = "y" ]; then \
189+
@if [ "$(CONFIG_DOCKER_COMPOSE_DEPLOY)" = "y" ]; then \
195190
make stop-docker-compose; \
196191
else \
197192
make stop-k8s; \
198193
fi
199194

200195
## Help rules
201196
clean-images:
197+
@echo "Clean all cello related images, may need to remove all containers"
202198
make clean
203-
echo "Clean all cello related images, may need to remove all containers before"
204-
docker images | grep "cello-" | awk '{print $3}' | xargs docker rmi -f
199+
@-docker images --filter=reference='hyperledger/*cello*' --format '{{.ID}}' | xargs -r docker rmi -f 2>/dev/null
200+
@echo "Images deleted!"
201+
@echo "Pruning dangling images..."
202+
docker image prune
203+
@echo "Dangling images pruned, cleanup finished!"
205204

206205
check-dashboard:
207206
docker compose -f tests/dashboard/docker-compose.yml up --abort-on-container-exit || (echo "check dashboard failed $$?"; exit 1)
@@ -253,4 +252,4 @@ dashboard:
253252
clean-images \
254253
start-docker-compose \
255254
stop-docker-compose \
256-
images \
255+
images \

0 commit comments

Comments
 (0)