-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (36 loc) · 1.4 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
PROJECT=quaive/ploneintranet-base
BASETAG=saturn
MARKER=$(shell cat LATEST)
OLDTAG=$(shell docker images quaive/ploneintranet-base | grep $(BASETAG) | grep -v latest | awk '{print $$2}' | sort -nr | head -1)
NEWTAG=$(shell echo ${OLDTAG} | sed -r 's/(.+\.)([0-9]+)/OLDTAG="\2"; NEWTAG=$$(( OLDTAG+1 )); echo "\1$$NEWTAG"/ge')
DATE = $(shell date +%Y%m%d)
version:
@echo LATEST marker: ${MARKER}
@echo old tag......: ${OLDTAG}
@echo new tag......: ${NEWTAG}
ifneq ($(MARKER),$(OLDTAG))
@echo "Error: LATEST marker does not match highest image tag."
@echo "If tags are missing, run 'make docker-pull && make docker-retag'"
@echo "To remove a brownbag build, run 'make docker-untag'"
endif
docker-build: version
ifeq ($(MARKER),$(OLDTAG))
docker build -t $(PROJECT):$(NEWTAG) --build-arg CACHEBUST=$(DATE) .
docker tag $(PROJECT):$(NEWTAG) $(PROJECT):latest
echo ${NEWTAG} > LATEST
@echo " "
@echo "Now commit LATEST so the new tag is git tracked, and run 'make docker-push'."
else
@echo "Aborting docker build. Maybe you need to do a docker pull first?"
endif
docker-run:
docker run -i -t $(PROJECT)
docker-push:
docker push $(PROJECT)
docker-pull:
docker pull $(PROJECT)
docker-retag:
docker tag $(PROJECT):latest $(PROJECT):$(MARKER)
docker-untag:
docker rmi $(PROJECT):$(MARKER)
docker images quaive/ploneintranet-base | grep $(BASETAG) | grep -v latest | awk '{print $$2}' | sort -nr | head -1 > LATEST