-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (48 loc) · 1.66 KB
/
Makefile
File metadata and controls
53 lines (48 loc) · 1.66 KB
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
#!/usr/bin/env make
SHELL := /bin/bash
repo := local
platform := linux/amd64,linux/arm64
default_dist := bookworm
targets := $(sort $(wildcard targets/*/*))
versions := $(sort $(wildcard versions/[0-9]*.env))
.PHONY: all
all: $(targets)
$(targets): targets/%: %
@true
%: versions/latest.env
@tgt=${@}; for filepath in $(versions); do \
source $${filepath}; \
dist="$${tgt##*/}" \
filename="$${filepath##*/}"; \
version="$${filename%.*}"; \
latest=$$(grep -iPo 'PG_MAJOR=\K[\S*].*' versions/latest.env); \
extraopts=$${extraopts:-'--load'}; \
if [ "$${dist}" == "$${default_dist}" ]; then \
extraopts="--tag $(repo)/postgres:$${PG_MAJOR} $${extraopts}"; \
extraopts="--tag $(repo)/postgres:$${PG_VERSION} $${extraopts}"; \
if [ "$${version}" == "$${latest}" ]; then \
extraopts="--tag $(repo)/postgres:latest $${extraopts}"; \
fi; \
fi; \
if [[ ! "$(skip-build)" =~ "$${version}" ]]; then \
[ 0$(DEBUG) -ne 0 ] && debug=-D; \
docker buildx $${debug} build . \
--file targets/$${tgt}/Dockerfile \
--platform $(platform) \
--build-arg PG_MAJOR=$${PG_MAJOR} \
--build-arg PG_VERSION=$${PG_VERSION} \
--tag "$(repo)/postgres:$${PG_MAJOR}-$${dist}" \
--tag "$(repo)/postgres:$${PG_VERSION}-$${dist}" \
$${extraopts} \
|| exit $${?}; \
fi; \
done
versions/latest.env:
@latest=1; for filepath in $(versions); do \
filename="$${filepath##*/}"; \
version="$${filename%.*}"; \
if [ $${version} -gt 0$${latest} ]; then \
latest=$${version}; \
fi; \
done; \
ln -snf $${latest}.env versions/latest.env