forked from Zayon/kanboard-redmine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (50 loc) · 1.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
.PHONY: all help build run builddocker rundocker kill rm-image rm clean enter logs
all: help
help:
@echo ""
@echo "-- Help Menu"
@echo "" 1. make run - build and run docker container
@echo "" 2. make build - build docker container
@echo "" 3. make clean - kill and remove docker container
@echo "" 4. make enter - execute an interactive bash in docker container
@echo "" 3. make logs - follow the logs of docker container
build: NAME TAG builddocker
# run a plain container
run: PORT NAME TAG build rundocker
rundocker:
$(eval TMP := $(shell mktemp -d --suffix=DOCKERTMP))
$(eval NAME := $(shell cat NAME))
$(eval TAG := $(shell cat TAG))
$(eval PORT := $(shell cat PORT))
chmod 777 $(TMP)
@docker run --name=$(NAME) \
--cidfile="cid" \
-v $(TMP):/tmp \
-d \
-p $(PORT):80 \
-t $(TAG)
builddocker:
/usr/bin/time -v docker build -t `cat TAG` .
kill:
-@docker kill `cat cid`
rm-image:
-@docker rm `cat cid`
-@rm cid
rm: kill rm-image
clean: rm
enter:
docker exec -i -t `cat cid` /bin/bash
logs:
docker logs -f `cat cid`
NAME:
@while [ -z "$$NAME" ]; do \
read -r -p "Enter the name you wish to associate with this container [NAME]: " NAME; echo "$$NAME">>NAME; cat NAME; \
done ;
TAG:
@while [ -z "$$TAG" ]; do \
read -r -p "Enter the tag you wish to associate with this container [TAG]: " TAG; echo "$$TAG">>TAG; cat TAG; \
done ;
PORT:
@while [ -z "$$PORT" ]; do \
read -r -p "Enter the tag you wish to associate with this container [PORT]: " PORT; echo "$$PORT">>PORT; cat PORT; \
done ;