-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (113 loc) · 3.8 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
version ?= develop
engine ?= podman
ns ?= quay.io/nitrate
baseimage ?=
package_name = nitrate-tcms
# NOTE: newer versions of setuptools (invoked via build) adhere to PEP 625
# It replaces - with _
normalised_sdist_name = nitrate_tcms
sdist = $(package_name)==$(version)
my_base_image = $(ns)/base:$(version)
web_image = $(ns)/web:$(version)
worker_image = $(ns)/worker:$(version)
gh_tarball_url = https://github.com/Nitrate/Nitrate/tarball/develop
gh_develop_archive = nitrate-tcms-develop.tar.gz
unset_labels = --unsetlabel=name --unsetlabel=license --unsetlabel=vendor --unsetlabel=version --unsetlabel=io.buildah.version
.PHONY: remove-app-tarball
remove-app-tarball:
@rm -f app.tar.gz
.PHONY: tarball-release
tarball-released: remove-app-tarball
python3 -m pip download --no-deps --no-binary :all: $(sdist)
for sdist_name in $(package_name) $(normalised_sdist_name); do \
if mv $${sdist_name}-$(version).tar.gz app.tar.gz 2>&1; then \
break; \
fi; \
done
GIT_REPO ?= https://github.com/Nitrate/Nitrate.git
.PHONY: tarball-develop
tarball-develop: remove-app-tarball
@if [ -e "./Nitrate/" ]; then rm -rf Nitrate; fi
@git clone $(GIT_REPO)
cd Nitrate && \
make sdist && \
for sdist_name in $(package_name) $(normalised_sdist_name); do \
if mv dist/$${sdist_name}-$$(cat VERSION.txt).tar.gz ../app.tar.gz >/dev/null 2>&1; then \
break; \
fi; \
done
ifeq ($(strip $(version)),develop)
tarball-generation=tarball-develop
else
tarball-generation=tarball-released
endif
.PHONY: base-image
base-image: $(tarball-generation)
ifeq ($(strip $(version)), develop)
$(engine) build -t $(my_base_image) -f Dockerfile-base \
$(if $(strip $(baseimage)),--build-arg base_image=$(baseimage),) \
--build-arg version=$$(git --git-dir Nitrate/.git describe) \
$(unset_labels) \
--label org.opencontainers.image.created=$(shell date --utc --iso-8601=seconds) \
--label org.opencontainers.image.revision=$(shell git --git-dir Nitrate/.git rev-parse HEAD) \
.
else
$(engine) build -t $(my_base_image) -f Dockerfile-base \
$(if $(strip $(baseimage)),--build-arg base_image=$(baseimage),) \
--build-arg version=$(version) \
$(unset_labels) \
--label org.opencontainers.image.created=$(shell date --utc --iso-8601=seconds) \
--label org.opencontainers.image.revision=$(shell sh -c "git ls-remote --tags --refs $(GIT_REPO) refs/tags/v$(version) | cut -f1") \
.
endif
.PHONY: web-image
web-image:
@$(engine) build -t $(web_image) -f Dockerfile-web \
--build-arg version=$(version) \
--build-arg ns=$(ns) \
--label org.opencontainers.image.created=$(shell date --utc --iso-8601=seconds) \
.
.PHONY: worker-image
worker-image:
@$(engine) build -t $(worker_image) -f Dockerfile-worker \
--build-arg version=$(version) \
--build-arg ns=$(ns) \
--label org.opencontainers.image.created=$(shell date --utc --iso-8601=seconds) \
.
.PHONY: all-images
all-images: base-image web-image worker-image
.PHONY: push-all
push-all: base-image web-image worker-image
@$(engine) push $(my_base_image)
@$(engine) push $(web_image)
@$(engine) push $(worker_image)
.PHONY: clean-images
clean-images:
@$(engine) rmi -f $(my_base_image)
@$(engine) rmi -f $(web_image)
@$(engine) rmi -f $(worker_image)
.PHONY: clean-artifacts
clean-artifacts:
rm -rf Nitrate/
rm -f $(package_name)-*.tar.gz
rm -f $(normalised_sdist_name)-*.tar.gz
.PHONY: clean
clean: clean-images clean-artifacts
# List nitrate related built images
.PHONY: list
list:
@$(engine) images $(ns)
.PHONY: images-overview
images-overview:
@echo $(my_base_image)
@echo $(web_image)
@echo $(worker_image)
.PHONY: lint-markdown
lint-markdown:
@markdownlint-cli2 README.md
.PHONY: lint-dockerfile
# Pin to hadolint 2.10.0
lint-dockerfile:
@hadolint --ignore DL3041 Dockerfile-base Dockerfile-web Dockerfile-worker
.PHONY: lint-all
lint-all: lint-markdown lint-dockerfile