-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.parent
40 lines (34 loc) · 1.1 KB
/
Makefile.parent
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
# This Makefile.parent defines all the rules you need for child projects
# All you need to do is define the below envars then 'include Makefile.parent'
#
# IMAGE_NAME=cyber
# DEPS=Dockerfile
# include ../Makefile.parent
KEEPFILE?=.imagebuild_$(shell echo $(IMAGE_NAME) | cut -d ':' -f 1)
DOCKER_USERNAME?=erezbinyamin
PUSHTAG?=latest
BFLAGS?=
RFLAGS?=-it --network host --privileged
build:$(KEEPFILE)
$(KEEPFILE): $(DEPS)
docker build $(BFLAGS) --tag $(IMAGE_NAME) .
touch $(KEEPFILE)
rebuild:
docker build $(BFLAGS) --no-cache --tag $(IMAGE_NAME) .
touch $(KEEPFILE)
bash: build
docker run $(RFLAGS) $(IMAGE_NAME)
clean:
docker images | grep -q "^$(IMAGE_NAME)" && docker image rm $(IMAGE_NAME) || true
rm -f $(KEEPFILE)
push:
docker tag $(IMAGE_NAME) $(DOCKER_USERNAME)/$(IMAGE_NAME):$(PUSHTAG)
docker push $(DOCKER_USERNAME)/$(IMAGE_NAME)
help:
@echo "Supported build targets:"
@echo " $(IMAGE_NAME): builds image"
@echo " build: .."
@echo " rebuild: .."
@echo " bash: launches shell inside container"
@echo " clean: removes docker image from local repository"
@echo " help: prints this help menu"