-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (96 loc) · 3.91 KB
/
Makefile
File metadata and controls
112 lines (96 loc) · 3.91 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
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
.PHONY: all push-all build-all build-push-all build-process build-push-process \
build-process-version build-push-process-version pgvector node-sqitch postgis clean
REPO_NAME?=pyramation
PLATFORMS?=linux/arm64
# default process if none specified (can be overridden: `make PROCESS=postgis build-process`)
PROCESS?=pgvector
# Convenience: list of known processes
PROCESSES:=pgvector node-sqitch postgis pgvector-postgis launchql
CONTAINER_NAME?=$(PROCESS)
## build-process builds docker image(s) for $(PROCESS) using base+versions from version.yaml
## It will build one image per version listed in $(PROCESS)/version.yaml and tag as <repo>/<process>:<version>
build-process:
@echo "==> Building process: $(PROCESS)"
@BASE=$$(sed -n 's/^[[:space:]]*base:[[:space:]]*//p' $(PROCESS)/version.yaml | head -n1); \
VERSIONS=$$(sed -n '/^[[:space:]]*versions:/,$$p' $(PROCESS)/version.yaml | sed -n 's/^[[:space:]]*-[[:space:]]*//p'); \
if [ -z "$$BASE" ] || [ -z "$$VERSIONS" ]; then \
echo "Error: Could not parse base or versions from $(PROCESS)/version.yaml" 1>&2; \
exit 1; \
fi; \
for v in $$VERSIONS; do \
$(MAKE) --no-print-directory BASE=$$BASE VERSION=$$v build-process-version || exit $$?; \
done
build-all:
@for p in $(PROCESSES); do \
$(MAKE) --no-print-directory PROCESS=$$p build-process || exit $$?; \
done
build-push-process:
@echo "==> Building+Pushing process: $(PROCESS)"
@BASE=$$(sed -n 's/^[[:space:]]*base:[[:space:]]*//p' $(PROCESS)/version.yaml | head -n1); \
VERSIONS=$$(sed -n '/^[[:space:]]*versions:/,$$p' $(PROCESS)/version.yaml | sed -n 's/^[[:space:]]*-[[:space:]]*//p'); \
if [ -z "$$BASE" ] || [ -z "$$VERSIONS" ]; then \
echo "Error: Could not parse base or versions from $(PROCESS)/version.yaml" 1>&2; \
exit 1; \
fi; \
for v in $$VERSIONS; do \
$(MAKE) --no-print-directory BASE=$$BASE VERSION=$$v build-push-process-version || exit $$?; \
done
build-push-all:
@for p in $(PROCESSES); do \
$(MAKE) --no-print-directory PROCESS=$$p build-push-process || exit $$?; \
done
# Build only a specific VERSION for $(PROCESS). Intended for internal use by build-process.
# Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-process-version
build-process-version:
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (build)"
@DOCKERFILE_PATH="$(PROCESS)/Dockerfile"; \
CONTEXT=$$( \
if [ "$(PROCESS)" = "launchql" ]; then \
echo ".."; \
else \
echo "$(PROCESS)"; \
fi ); \
docker buildx build \
--platform $(PLATFORMS) \
--build-arg BASE=$(BASE) \
--build-arg BASE_VERSION=$(VERSION) \
--file $$DOCKERFILE_PATH \
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
$$CONTEXT
# Build+push only a specific VERSION for $(PROCESS). Intended for internal use by build-push-process.
# Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-push-process-version
build-push-process-version:
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (push)"
@DOCKERFILE_PATH="$(PROCESS)/Dockerfile"; \
CONTEXT=$$( \
if [ "$(PROCESS)" = "launchql" ]; then \
echo ".."; \
else \
echo "$(PROCESS)"; \
fi ); \
docker buildx build \
--platform $(PLATFORMS) \
--build-arg BASE=$(BASE) \
--build-arg BASE_VERSION=$(VERSION) \
--file $$DOCKERFILE_PATH \
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
--push \
$$CONTEXT
# Aliases
all: build-all
push-all: build-push-all
# Convenience per-process targets
pgvector:
$(MAKE) PROCESS=pgvector build-process
node-sqitch:
$(MAKE) PROCESS=node-sqitch build-process
postgis:
$(MAKE) PROCESS=postgis build-process
pgvector-postgis:
$(MAKE) PROCESS=pgvector-postgis build-process
launchql:
$(MAKE) PROCESS=launchql build-process