upg: makefile +upgraded makefile verbosity

This commit is contained in:
xdrm-brackets 2018-02-16 14:55:00 +01:00
parent 994882a21f
commit 8ef603407c
1 changed files with 42 additions and 24 deletions

View File

@ -4,44 +4,62 @@ LOG="/tmp/ptut.virtenv.log"
LOCK="/tmp/ptut.virtenv.lock"
image: build
@echo -n "> Building image...............";
docker build --force-rm -t $(IMAGE_NAME) . && echo "done" || echo "error";
@echo -n "> Build image..................";
@docker build --force-rm -t $(IMAGE_NAME) . >>$(LOG) 2>&1 && echo "done" || echo "error";
build: docker/main docker/include/*
@echo -n "> Building file Dockerfile.....";
@echo -n "> Build Dockerfile.............";
@cpp -o Dockerfile docker/main && echo "done" || echo "error";
clean:
@echo -n "> Stopping containers..........";
@docker stop $(CONTAINER_NAME); true;
@docker rm -flv $(CONTAINER_NAME); true;
@echo -n "> Deleting docker image........";
@docker rmi -f $(IMAGE_NAME) && echo "done" || echo "failed"; true
@echo -n "> Deleting Dockerfile..........";
@rm Dockerfile && echo "done" || echo "failed"; true
@echo -n "> Stop container...............";
@docker stop $(CONTAINER_NAME) >/dev/null 2>&1 && echo "stopped" || echo "already"; true;
@echo -n "> Delete container.............";
@docker rm -f $(CONTAINER_NAME) >/dev/null 2>&1 && echo "deleted" || echo "already"; true;
@echo -n "> Delete image.................";
@docker rmi -f $(IMAGE_NAME) >/dev/null 2>&1 && echo "deleted" || echo "already"; true;
@echo -n "> Delete Dockerfile............";
@rm Dockerfile >/dev/null 2>&1 && echo "done" || echo "already"; true
@echo -n "> Delete log file..............";
@rm $(LOG) >/dev/null 2>&1 && echo "done" || echo "already"; true
@echo -n "> Delete lock file.............";
@rm $(LOCK) >/dev/null 2>&1 && echo "done" || echo "already"; true
run: image
@echo "> Launching the container";
docker run --name $(CONTAINER_NAME) $(IMAGE_NAME);
run:
@echo ">>> Search running container";
@test ! -f $(LOCK) && echo -e "<<< nothing\n" || (echo -e "<<< found\n\nERR: You must run 'make clean' before running a new container"; exit 1);
@echo ">>> Build image";
@make image;
@echo -e "<<< built\n";
@echo ">>> Container launched";
@touch $(LOCK);
@docker run --name $(CONTAINER_NAME) $(IMAGE_NAME);
@echo -e "<<< stopped\n";
@echo ">>> clean installation" | tee -a $(LOG); \
make clean;
@echo "<<< cleaned";
kill:
@docker exec -ti inst1 sh -c 'rm boot.lock';
@echo -n "Search running container.......";
@test -f $(LOCK) && echo "found" || (echo -e "nothing\n\nERR: You must run a container to kill it"; exit 1);
@echo -n "Kill container.................";
@docker exec -ti inst1 sh -c 'rm boot.lock' && echo "killed" || echo "error";
boot:
@echo -e "/!\\ 'make log' for real-time log\n";
@touch $(LOG);
@while true; do \
echo "*** 1. Updating virtual environment" | tee -a $(LOG); \
git pull origin master >> $(LOG) 2>&1; true; \
echo "*** 2. Building image" | tee -a $(LOG); \
make image >> $(LOG) 2>&1; \
echo "*** 3. Launching container" | tee -a $(LOG); \
echo ">>> pull from source" | tee -a $(LOG); \
git pull origin master >> $(LOG) 2>&1 && echo -e "<<< pulled\n" || echo -e "<<< error\n"; \
echo ">>> make image" | tee -a $(LOG); \
make image; \
echo -e ">>> made\n" | tee -a $(LOG); \
echo ">>> launch container" | tee -a $(LOG); \
touch $(LOCK); \
docker run --name $(CONTAINER_NAME) $(IMAGE_NAME) >> $(LOG) 2>&1; \
echo "*** 4. Deleting container" | tee -a; \
docker stop $(CONTAINER_NAME) >> $(LOG) 2>&1; true; \
docker rm -flv $(CONTAINER_NAME) >> $(LOG) 2>&1; true; \
rm $(LOCK); \
echo -e "<<< stopped\n" | tee -a $(LOG); \
echo ">>> clean installation" | tee -a $(LOG); \
make clean; \
echo -e "<<< cleaned\n"; \
sleep 2; \
done;