-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
59 lines (42 loc) · 1.69 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
ifneq (,)
.error This Makefile requires GNU Make.
endif
# -------------------------------------------------------------------------------------------------
# Docker configuration
# -------------------------------------------------------------------------------------------------
DIR = .
FILE = Dockerfile
IMAGE = devilbox/haproxy
TAG = latest
.PHONY: help build rebuild test tag pull login push enter
# -------------------------------------------------------------------------------------------------
# DEFAULT TARGET
# -------------------------------------------------------------------------------------------------
help:
@echo "build Build Docker image"
@echo "rebuild Rebuild Docker image without cache"
@echo "tag [TAG=] Tag Docker image"
@echo "pull Pull latest base image"
@echo "login USER= PASS= Login to Dockerhub"
@echo "push [TAG=] Push Docker image (and retag)"
@echo "enter Spawn bash and enter Docker image"
# -------------------------------------------------------------------------------------------------
# GENERATE TARGETS
# -------------------------------------------------------------------------------------------------
build:
docker build -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
rebuild: pull
docker build --no-cache -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
test:
./tests/test.sh $(IMAGE)
tag:
docker tag $(IMAGE) $(IMAGE):$(TAG)
pull:
docker pull $(shell grep FROM Dockerfile | sed 's/^FROM//g';)
login:
yes | docker login --username $(USER) --password $(PASS)
push:
@$(MAKE) tag TAG=$(TAG)
docker push $(IMAGE):$(TAG)
enter:
docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=bash $(ARG) $(IMAGE)