upd: makefile,readme +added proper log/lock files +added 'make log' +added 'make tty'

This commit is contained in:
xdrm-brackets 2018-02-16 10:46:16 +01:00
parent aea9ee2ddc
commit 994882a21f
2 changed files with 34 additions and 11 deletions

View File

@ -1,5 +1,7 @@
IMAGE_NAME="alp-mdb" IMAGE_NAME="alp-mdb"
CONTAINER_NAME="inst1" CONTAINER_NAME="inst1"
LOG="/tmp/ptut.virtenv.log"
LOCK="/tmp/ptut.virtenv.lock"
image: build image: build
@echo -n "> Building image..............."; @echo -n "> Building image...............";
@ -26,15 +28,33 @@ kill:
@docker exec -ti inst1 sh -c 'rm boot.lock'; @docker exec -ti inst1 sh -c 'rm boot.lock';
boot: boot:
@echo -e "/!\\ 'make log' for real-time log\n";
@touch $(LOG);
@while true; do \ @while true; do \
echo "*** 1. Updating virtual environment"; \ echo "*** 1. Updating virtual environment" | tee -a $(LOG); \
git pull; \ git pull origin master >> $(LOG) 2>&1; true; \
echo "*** 2. Building image"; \ echo "*** 2. Building image" | tee -a $(LOG); \
make image; \ make image >> $(LOG) 2>&1; \
echo "*** 3. Launching container"; \ echo "*** 3. Launching container" | tee -a $(LOG); \
docker run --name $(CONTAINER_NAME) $(IMAGE_NAME); \ touch $(LOCK); \
echo "*** 4. Deleting container"; \ docker run --name $(CONTAINER_NAME) $(IMAGE_NAME) >> $(LOG) 2>&1; \
docker stop $(CONTAINER_NAME); \ echo "*** 4. Deleting container" | tee -a; \
docker rm -flv $(CONTAINER_NAME); \ docker stop $(CONTAINER_NAME) >> $(LOG) 2>&1; true; \
docker rm -flv $(CONTAINER_NAME) >> $(LOG) 2>&1; true; \
rm $(LOCK); \
sleep 2; \ sleep 2; \
done; 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;

View File

@ -64,4 +64,7 @@ make boot
1. Updates the git repository (*git pull*) 1. Updates the git repository (*git pull*)
2. Builds the image (*make image*) 2. Builds the image (*make image*)
3. Launches the container (*make run*) 3. Launches the container (*make run*)
4. When the container stops, delete it and reloop 4. When the container stops, delete it and reloop
- to have a real time log, launch `make log`
- to connect to a tty launch `make tty`