forked from CrunchyData/crunchy-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
343 lines (285 loc) · 12.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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
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.4
CCP_PATRONI_VERSION ?= 2.0.0
CCP_BACKREST_VERSION ?= 2.29
CCP_VERSION ?= 4.5.0-rc.1
CCP_POSTGIS_VERSION ?= 3.0
PACKAGER ?= yum
# Valid values: buildah (default), docker
IMGBUILDER ?= buildah
# Determines whether or not images should be pushed to the local docker daemon when building with
# a tool other than docker (e.g. when building with buildah)
IMG_PUSH_TO_DOCKER_DAEMON ?= true
# Defines the sudo command that should be prepended to various build commands when rootless builds are
# not enabled
IMGCMDSUDO=
ifneq ("$(IMG_ROOTLESS_BUILD)", "true")
IMGCMDSUDO=sudo --preserve-env
endif
IMGCMDSTEM=$(IMGCMDSUDO) buildah bud --layers $(SQUASH)
DFSET=$(CCP_BASEOS)
DOCKERBASEREGISTRY=registry.access.redhat.com/
# Default the buildah format to docker to ensure it is possible to pull the images from a docker
# repository using docker (otherwise the images may not be recognized)
export BUILDAH_FORMAT ?= docker
# Allows simplification of IMGBUILDER switching
ifeq ("$(IMGBUILDER)","docker")
IMGCMDSTEM=docker build
endif
# Allows consolidation of ubi/rhel Dockerfile sets
ifeq ("$(CCP_BASEOS)", "rhel7")
DFSET=rhel
endif
ifeq ("$(CCP_BASEOS)", "ubi7")
DFSET=rhel
endif
ifeq ("$(CCP_BASEOS)", "ubi8")
DFSET=rhel
PACKAGER=dnf
endif
ifeq ("$(CCP_BASEOS)", "centos7")
DFSET=centos
DOCKERBASEREGISTRY=centos:
endif
ifeq ("$(CCP_BASEOS)", "centos8")
DFSET=centos
PACKAGER=dnf
DOCKERBASEREGISTRY=centos:
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 pgpool
# Build images that require a specific postgres version - ordered for potential concurrent benefits
pgimages: postgres postgres-ha backrestrestore crunchyadm postgres-gis postgres-gis-ha pgdump pgrestore upgrade
#===========================================
# Targets generating pg-based images
#===========================================
backrestrestore: backrest-restore-pgimg-$(IMGBUILDER)
backup: backup-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
#===========================================
pgbasebackuprestore: pgbasebackup-restore-img-$(IMGBUILDER)
#===========================================
# Pattern-based image generation targets
#===========================================
$(CCPROOT)/build/%/Dockerfile:
$(error No Dockerfile found for $* naming pattern: [$@])
# ----- Base Image -----
ccbase-image: ccbase-image-$(IMGBUILDER)
ccbase-image-build: $(CCPROOT)/build/base/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/base/Dockerfile \
-t $(CCP_IMAGE_PREFIX)/crunchy-base:$(CCP_IMAGE_TAG) \
--build-arg BASEOS=$(CCP_BASEOS) \
--build-arg RELVER=$(CCP_VERSION) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
--build-arg DOCKERBASEREGISTRY=$(DOCKERBASEREGISTRY) \
$(CCPROOT)
ccbase-image-buildah: ccbase-image-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-base:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-base:$(CCP_IMAGE_TAG)
endif
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)/build/pg-base/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/pg-base/Dockerfile \
-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) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
cc-pg-base-image-buildah: cc-pg-base-image-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
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)
endif
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)/build/postgres/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/postgres/Dockerfile \
-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) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
postgres-pgimg-buildah: postgres-pgimg-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres:$(CCP_IMAGE_TAG)
endif
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)/build/postgres-gis/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/postgres-gis/Dockerfile \
-t $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis:$(CCP_POSTGIS_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)) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
postgres-gis-pgimg-buildah: postgres-gis-pgimg-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis:$(CCP_POSTGIS_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres-gis:$(CCP_POSTGIS_IMAGE_TAG)
endif
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)/build/postgres-ha/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/postgres-ha/Dockerfile \
-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) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
postgres-ha-pgimg-buildah: postgres-ha-pgimg-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
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)
endif
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)/build/postgres-gis-ha/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/postgres-gis-ha/Dockerfile \
-t $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis-ha:$(CCP_POSTGIS_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)) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
postgres-gis-ha-pgimg-buildah: postgres-gis-ha-pgimg-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-postgres-gis-ha:$(CCP_POSTGIS_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-postgres-gis-ha:$(CCP_POSTGIS_IMAGE_TAG)
endif
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)/build/backrest-restore/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/backrest-restore/Dockerfile \
-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) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
backrest-restore-pgimg-buildah: backrest-restore-pgimg-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
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)
endif
backrest-restore-pgimg-docker: backrest-restore-pgimg-build
# ----- All other pg-based images ----
%-pgimg-build: cc-pg-base-image $(CCPROOT)/build/%/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/$*/Dockerfile \
-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) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
%-pgimg-buildah: %-pgimg-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG)
endif
%-pgimg-docker: %-pgimg-build ;
# ----- Extra images -----
%-img-build: ccbase-image $(CCPROOT)/build/%/Dockerfile
$(IMGCMDSTEM) \
-f $(CCPROOT)/build/$*/Dockerfile \
-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) \
--build-arg DFSET=$(DFSET) \
--build-arg PACKAGER=$(PACKAGER) \
$(CCPROOT)
%-img-buildah: %-img-build ;
# only push to docker daemon if variable PGO_PUSH_TO_DOCKER_DAEMON is set to "true"
ifeq ("$(IMG_PUSH_TO_DOCKER_DAEMON)", "true")
sudo --preserve-env buildah push $(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG) docker-daemon:$(CCP_IMAGE_PREFIX)/crunchy-$*:$(CCP_IMAGE_TAG)
endif
%-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