2018-02-16 00:49:02 +00:00
|
|
|
IMAGE_NAME="alp-mdb"
|
2018-02-16 09:24:16 +00:00
|
|
|
CONTAINER_NAME="inst1"
|
2018-02-16 09:46:16 +00:00
|
|
|
LOG="/tmp/ptut.virtenv.log"
|
|
|
|
LOCK="/tmp/ptut.virtenv.lock"
|
2018-02-16 00:49:02 +00:00
|
|
|
|
2018-02-16 09:24:16 +00:00
|
|
|
image: build
|
2018-02-16 13:55:00 +00:00
|
|
|
@echo -n "> Build image..................";
|
|
|
|
@docker build --force-rm -t $(IMAGE_NAME) . >>$(LOG) 2>&1 && echo "done" || echo "error";
|
2018-02-16 00:49:02 +00:00
|
|
|
|
2018-02-16 09:24:16 +00:00
|
|
|
build: docker/main docker/include/*
|
2018-02-16 13:55:00 +00:00
|
|
|
@echo -n "> Build Dockerfile.............";
|
2018-02-16 00:49:02 +00:00
|
|
|
@cpp -o Dockerfile docker/main && echo "done" || echo "error";
|
|
|
|
|
|
|
|
clean:
|
2018-02-16 13:55:00 +00:00
|
|
|
@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:
|
|
|
|
@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";
|
2018-02-16 09:24:16 +00:00
|
|
|
|
|
|
|
kill:
|
2018-02-16 13:55:00 +00:00
|
|
|
@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";
|
2018-02-16 00:49:02 +00:00
|
|
|
|
|
|
|
boot:
|
2018-02-16 09:46:16 +00:00
|
|
|
@touch $(LOG);
|
2018-02-16 00:49:02 +00:00
|
|
|
@while true; do \
|
2018-02-16 13:55:00 +00:00
|
|
|
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); \
|
2018-02-16 09:46:16 +00:00
|
|
|
touch $(LOCK); \
|
|
|
|
docker run --name $(CONTAINER_NAME) $(IMAGE_NAME) >> $(LOG) 2>&1; \
|
2018-02-16 13:55:00 +00:00
|
|
|
echo -e "<<< stopped\n" | tee -a $(LOG); \
|
|
|
|
echo ">>> clean installation" | tee -a $(LOG); \
|
|
|
|
make clean; \
|
|
|
|
echo -e "<<< cleaned\n"; \
|
2018-02-16 00:49:02 +00:00
|
|
|
sleep 2; \
|
2018-02-16 09:46:16 +00:00
|
|
|
done;
|
|
|
|
|
|
|
|
log:
|
|
|
|
@echo -n "> Checking log file.......";
|
|
|
|
@test -f $(LOG) && echo "found" || (echo "missing"; exit 1);
|
|
|
|
@echo -n "> Checking container......";
|
|
|
|
@test -f $(LOCK) && echo "running" || echo "not running";
|
|
|
|
@echo "====== LOG ======";
|
|
|
|
@tail -f $(LOG);
|
|
|
|
|
|
|
|
tty:
|
|
|
|
@echo -n "> Checking lock...........";
|
|
|
|
@test -f $(LOCK) && echo "found" || (echo "missing"; exit 1);
|
|
|
|
@echo "> Connecting tty.............";
|
|
|
|
@docker exec -ti $(CONTAINER_NAME) sh;
|