forked from CrunchyData/crunchy-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
278 lines (219 loc) · 10.2 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
ifndef CCPROOT
export CCPROOT=$(GOPATH)/src/github.com/crunchydata/crunchy-containers
endif
# Default values if not already set
CCP_BASEOS ?= centos7
CCP_PGVERSION ?= 12
CCP_PG_FULLVERSION ?= 12.2
CCP_PATRONI_VERSION ?= 1.6.5
CCP_BACKREST_VERSION ?= 2.25
CCP_VERSION ?= 4.3.0
CCP_POSTGIS_VERSION ?= 2.5
# Valid values: buildah (default), docker
IMGBUILDER ?= buildah
IMGCMDSTEM=sudo --preserve-env buildah bud --layers $(SQUASH)
DFSET=$(CCP_BASEOS)
# Allows simplification of IMGBUILDER switching
ifeq ("$(IMGBUILDER)","docker")
IMGCMDSTEM=docker build
endif
# Allows consolidation of ubi/rhel Dockerfile sets
ifeq ("$(CCP_BASEOS)", "ubi7")
DFSET=rhel7
endif
.PHONY: all pg-independent-images pgimages
# Default target
all: cc-pg-base-image pgimages pg-independent-images
# Build images that either don't have a PG dependency or using the latest PG version is all that is needed
pg-independent-images: backup pgadmin4 pgbadger pgbasebackuprestore pgbench pgbouncer pgdump pgpool grafana prometheus
# Build images that require a specific postgres version - ordered for potential concurrent benefits
pgimages: postgres postgres-ha backrestrestore collect crunchyadm postgres-gis postgres-gis-ha pgrestore upgrade
#===========================================
# Targets generating commands
#===========================================
commands: pgc
pgc:
cd $(CCPROOT)/commands/pgc && go build pgc.go && mv pgc $(GOBIN)/pgc
cp $(GOBIN)/pgc bin/postgres
#===========================================
# Targets generating pg-based images
#===========================================
backrestrestore: backrest-restore-pgimg-$(IMGBUILDER)
backup: backup-pgimg-$(IMGBUILDER)
collect: collect-pgimg-$(IMGBUILDER)
crunchyadm: admin-pgimg-$(IMGBUILDER)
pgadmin4: pgadmin4-pgimg-$(IMGBUILDER)
pgbadger: pgbadger-pgimg-$(IMGBUILDER)
pgbench: pgbench-pgimg-$(IMGBUILDER)
pgbouncer: pgbouncer-pgimg-$(IMGBUILDER)
pgdump: pgdump-pgimg-$(IMGBUILDER)
pgpool: pgpool-pgimg-$(IMGBUILDER)
pgrestore: pgrestore-pgimg-$(IMGBUILDER)
postgres: postgres-pgimg-$(IMGBUILDER)
postgres-ha: postgres-ha-pgimg-$(IMGBUILDER)
postgres-gis: postgres-gis-pgimg-$(IMGBUILDER)
postgres-gis-ha: postgres-gis-ha-pgimg-$(IMGBUILDER)
postgres-appdev: commands postgres-appdev-pgimg-$(IMGBUILDER)
#===========================================
# Targets generating non-pg-based images
#===========================================
grafana: grafana-img-$(IMGBUILDER)
pgbasebackuprestore: pgbasebackup-restore-img-$(IMGBUILDER)
prometheus: prometheus-img-$(IMGBUILDER)
#===========================================
# Pattern-based image generation targets
#===========================================
$(CCPROOT)/$(DFSET)/Dockerfile.%.$(DFSET):
$(error No Dockerfile found for $* naming pattern: [$@])
# ----- Base Image -----
ccbase-image: ccbase-image-$(IMGBUILDER)
ccbase-image-build: $(CCPROOT)/$(DFSET)/Dockerfile.base.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.base.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-base:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg RELVER=$(CCP_VERSION) \
$(CCPROOT)
ccbase-image-buildah: ccbase-image-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-base:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-base:$(CCP_IMAGE_TAG)
ccbase-image-docker: ccbase-image-build
# ----- PG Base Image -----
cc-pg-base-image: cc-pg-base-image-$(IMGBUILDER)
cc-pg-base-image-build: ccbase-image $(CCPROOT)/$(DFSET)/Dockerfile.pg-base.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.pg-base.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-pg-base:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_LBL=$(subst .,,$(CCP_PGVERSION)) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
$(CCPROOT)
cc-pg-base-image-buildah: cc-pg-base-image-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-pg-base:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-pg-base:$(CCP_IMAGE_TAG)
cc-pg-base-image-docker: cc-pg-base-image-build
# ----- Special case pg-based image (postgres) -----
# Special case args: BACKREST_VER
postgres-pgimg-build: cc-pg-base-image commands $(CCPROOT)/$(DFSET)/Dockerfile.postgres.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.postgres.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-postgres:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
--build-arg BACKREST_VER=$(CCP_BACKREST_VERSION) \
$(CCPROOT)
postgres-pgimg-buildah: postgres-pgimg-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres:$(CCP_IMAGE_TAG)
postgres-pgimg-docker: postgres-pgimg-build
# ----- Special case pg-based image (postgres-gis) -----
# Special case args: POSTGIS_LBL
postgres-gis-pgimg-build: postgres commands $(CCPROOT)/$(DFSET)/Dockerfile.postgres-gis.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.postgres-gis.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
--build-arg POSTGIS_LBL=$(subst .,,$(CCP_POSTGIS_VERSION)) \
$(CCPROOT)
postgres-gis-pgimg-buildah: postgres-gis-pgimg-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres-gis:$(CCP_IMAGE_TAG)
postgres-gis-pgimg-docker: postgres-gis-pgimg-build
# ----- Special case pg-based image (postgres-ha) -----
# Special case args: BACKREST_VER, PATRONI_VER
postgres-ha-pgimg-build: cc-pg-base-image commands $(CCPROOT)/$(DFSET)/Dockerfile.postgres-ha.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.postgres-ha.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-postgres-ha:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
--build-arg BACKREST_VER=$(CCP_BACKREST_VERSION) \
--build-arg PATRONI_VER=$(CCP_PATRONI_VERSION) \
$(CCPROOT)
postgres-ha-pgimg-buildah: postgres-ha-pgimg-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres-ha:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres-ha:$(CCP_IMAGE_TAG)
postgres-ha-pgimg-docker: postgres-ha-pgimg-build
# ----- Special case pg-based image (postgres-gis-ha) -----
# Special case args: POSTGIS_LBL
postgres-gis-ha-pgimg-build: postgres-ha commands $(CCPROOT)/$(DFSET)/Dockerfile.postgres-gis-ha.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.postgres-gis-ha.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis-ha:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
--build-arg POSTGIS_LBL=$(subst .,,$(CCP_POSTGIS_VERSION)) \
$(CCPROOT)
postgres-gis-ha-pgimg-buildah: postgres-gis-ha-pgimg-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis-ha:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres-gis-ha:$(CCP_IMAGE_TAG)
postgres-gis-ha-pgimg-docker: postgres-gis-ha-pgimg-build
# ----- Special case pg-based image (backrest-restore) -----
# Special case args: BACKREST_VER
backrest-restore-pgimg-build: cc-pg-base-image $(CCPROOT)/$(DFSET)/Dockerfile.backrest-restore.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.backrest-restore.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-backrest-restore:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
--build-arg BACKREST_VER=$(CCP_BACKREST_VERSION) \
$(CCPROOT)
backrest-restore-pgimg-buildah: backrest-restore-pgimg-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-backrest-restore:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-backrest-restore:$(CCP_IMAGE_TAG)
backrest-restore-pgimg-docker: backrest-restore-pgimg-build
# ----- All other pg-based images ----
%-pgimg-build: cc-pg-base-image $(CCPROOT)/$(DFSET)/Dockerfile.%.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.$*.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
$(CCPROOT)
%-pgimg-buildah: %-pgimg-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG)
%-pgimg-docker: %-pgimg-build ;
# ----- Extra images -----
%-img-build: ccbase-image $(CCPROOT)/$(DFSET)/Dockerfile.%.$(DFSET)
$(IMGCMDSTEM) \
-f $(CCPROOT)/$(DFSET)/Dockerfile.$*.$(DFSET) \
-t $(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg BASEVER=$(CCP_VERSION) \
--build-arg PG_FULL=$(CCP_PG_FULLVERSION) \
--build-arg PG_MAJOR=$(CCP_PGVERSION) \
--build-arg PREFIX=$(CCP_IMAGE_PREFIX) \
$(CCPROOT)
%-img-buildah: %-img-build
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG)
%-img-docker: %-img-build ;
# ----- Upgrade Images -----
upgrade: upgrade-$(CCP_PGVERSION)
upgrade-%: upgrade-pgimg-$(IMGBUILDER) ;
upgrade-9.5: # Do nothing but log to avoid erroring out on missing Dockerfile
$(info Upgrade build skipped for 9.5)
#=================
# Utility targets
#=================
setup:
$(CCPROOT)/bin/install-deps.sh
docbuild:
cd $(CCPROOT) && ./generate-docs.sh
push:
./bin/push-to-dockerhub.sh
-include Makefile.build