This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.docker
74 lines (58 loc) · 2 KB
/
Makefile.docker
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
66
67
68
69
70
71
72
73
74
DOCKER_NAMESPACE=nouchka
.DEFAULT_GOAL := build
.PHONY: build-latest
build-latest:
$(MAKE) -s build-version VERSION=latest
.PHONY: build-beta
build-beta:
$(MAKE) -s build-version VERSION=beta
.PHONY: build-version
build-version:
test ! -f ./hooks/build || chmod +x ./hooks/build
test ! -f ./hooks/build || DOCKER_TAG=$(VERSION) IMAGE_NAME=$(DOCKER_NAMESPACE)/$(DOCKER_IMAGE):$(VERSION) ./hooks/build
ifeq ($(VERSION),latest)
test -f ./hooks/build || docker build -t $(DOCKER_NAMESPACE)/$(DOCKER_IMAGE):$(VERSION) --build-arg=DOCKER_TAG=$(VERSION) .
else
test -f ./hooks/build || docker build -t $(DOCKER_NAMESPACE)/$(DOCKER_IMAGE):$(VERSION) --build-arg=DOCKER_TAG=$(VERSION) --build-arg=VERSION=$(VERSION) .
endif
.PHONY: build
build: build-latest
$(foreach version,$(VERSIONS), $(MAKE) -s build-version VERSION=$(version);)
.PHONY: push-latest
push-latest:
$(MAKE) -s push-version VERSION=latest
.PHONY: push-beta
push-beta:
$(MAKE) -s push-version VERSION=beta
.PHONY: push-version
push-version:
docker push $(DOCKER_NAMESPACE)/$(DOCKER_IMAGE):$(VERSION)
.PHONY: push-versions
push-versions:
$(foreach version,$(VERSIONS), $(MAKE) -s push-version VERSION=$(version);)
.PHONY: push
push: push-versions push-latest
.PHONY: check
check:
$(MAKE) -s check-version VERSION=latest
$(foreach version,$(VERSIONS), $(MAKE) -s check-version VERSION=$(version);)
.PHONY: update-version
update-version:
touch VERSION
rm VERSION
$(MAKE) -s check >> VERSION
.PHONY: update-dockerfile
update-dockerfile: update-version
sed -i '/MINOR_TAGS/c\## MINOR_TAGS=$(shell cat VERSION)' Dockerfile
sed -i '/LATEST_RELEASE/c\## LATEST_RELEASE=$(shell make -s check-version VERSION=latest)' Dockerfile
.PHONY: test
test:
docker-compose -f docker-compose.test.yml up
hadolint:
docker run --rm -i hadolint/hadolint < Dockerfile 2>/dev/null; true
.PHONY: clean
clean:
$(foreach version,$(VERSIONS), $(MAKE) -s clean-version VERSION=$(version);)
.PHONY: clean-version
clean-version:
docker rmi $(DOCKER_NAMESPACE)/$(DOCKER_IMAGE):$(VERSION)