-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
200 lines (164 loc) · 7.57 KB
/
Makefile
File metadata and controls
200 lines (164 loc) · 7.57 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
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
# SPDX-License-Identifier: MPL-2.0
BASE ?= trixie
RELEASE_TAG ?= latest
VERSION_NS ?= GIT
DOCKER_USERNAME ?= gustafn
DOCKER_PROGRESS ?= plain
PLATFORM ?= linux/amd64,linux/arm64
SYSTEM_PKGS ?=
LOCAL_TAG ?=
export BASE RELEASE_TAG VERSION_NS DOCKER_USERNAME DOCKER_PROGRESS PLATFORM SYSTEM_PKGS LOCAL_TAG
VERSION_NS_NORM := $(if $(strip $(VERSION_NS)),$(VERSION_NS),default)
LOCAL_TAG_NORM := $(if $(strip $(LOCAL_TAG)),$(LOCAL_TAG),)
STAMP_BUILD := .built-$(BASE)-$(RELEASE_TAG)-$(VERSION_NS_NORM)$(LOCAL_TAG_NORM)
STAMP_BUILDX_MAN := .builtx-manifest-$(BASE)-$(RELEASE_TAG)-$(VERSION_NS_NORM)
CORE_COMPONENTS = \
naviserver \
naviserver-pg \
openacs
# Currently, there is a problem with
# naviserver-oracle
# Downloaded Oracle instantclient-basiclite-linux-arm64.zip size -rw-r--r-- 1 root root 7073 Feb 11 07:44 instantclient-basiclite.zip
# Archive: instantclient-basiclite.zip
# End-of-central-directory signature not found. Either this file is not
# a zipfile, or it constitutes one disk of a multi-part archive. In the
# latter case the central directory and zipfile comment will be found on
# the last disk(s) of this archive.
# unzip: cannot find zipfile directory in one of instantclient-basiclite.zip or
# instantclient-basiclite.zip.zip, and cannot find instantclient-basiclite.zip.ZIP, period.
ALPINE_ONLY_COMPONENTS = \
munin-master \
munin-node \
mail-relay
BOLD := \033[1m
RESET := \033[0m
.PHONY: all build buildx sync clean help
# $(addprefix build-,$(CORE_COMPONENTS) $(ALPINE_ONLY_COMPONENTS)) \
# $(addprefix buildx-,$(CORE_COMPONENTS) $(ALPINE_ONLY_COMPONENTS))
all: build
# ---- shared sync rules ----
sync: openacs/scripts/oacs-db-env.sh \
munin-node/oacs-db-env.sh \
naviserver/get-naviserver-modules.sh \
naviserver-pg/get-naviserver-modules.sh \
naviserver-oracle/get-naviserver-modules.sh \
openacs/scripts/get-naviserver-modules.sh \
naviserver/ns-certificates.sh \
openacs/scripts/ns-certificates.sh
openacs/scripts/oacs-db-env.sh: scripts/oacs-db-env.sh
cp -p $< $@
munin-node/oacs-db-env.sh: scripts/oacs-db-env.sh
cp -p $< $@
NSMOD_TARGETS = \
naviserver/get-naviserver-modules.sh \
naviserver-pg/get-naviserver-modules.sh \
naviserver-oracle/get-naviserver-modules.sh \
openacs/scripts/get-naviserver-modules.sh
$(NSMOD_TARGETS): scripts/get-naviserver-modules.sh
cp -p $< $@
CERT_TARGETS = \
naviserver/ns-certificates.sh \
openacs/scripts/ns-certificates.sh
$(CERT_TARGETS): scripts/ns-certificates.sh
cp -p $< $@
# ----------------------------------------------------------------------
# Stamp dependency chain (core images)
# ----------------------------------------------------------------------
# naviserver has no base dependency
naviserver/$(STAMP_BUILD): sync
$(MAKE) -C naviserver build
naviserver/$(STAMP_BUILDX_MAN): sync
$(MAKE) -C naviserver buildx
# naviserver-pg depends on naviserver
naviserver-pg/$(STAMP_BUILD): naviserver/$(STAMP_BUILD) sync
$(MAKE) -C naviserver-pg build BASE_STAMP=../naviserver/$(STAMP_BUILD)
naviserver-pg/$(STAMP_BUILDX_MAN): naviserver/$(STAMP_BUILDX_MAN) sync
$(MAKE) -C naviserver-pg buildx BASE_STAMP=../naviserver/$(STAMP_BUILDX_MAN)
# naviserver-oracle depends on naviserver
naviserver-oracle/$(STAMP_BUILD): naviserver/$(STAMP_BUILD) sync
$(MAKE) -C naviserver-oracle build STAMP=../naviserver/$(STAMP_BUILD)
naviserver-oracle/$(STAMP_BUILDX_MAN): naviserver/$(STAMP_BUILDX_MAN) sync
$(MAKE) -C naviserver-oracle buildx BASE_STAMP=../naviserver/$(STAMP_BUILDX_MAN)
# openacs depends on naviserver-pg
openacs/$(STAMP_BUILD): naviserver-pg/$(STAMP_BUILD) sync
$(MAKE) -C openacs build BASE_STAMP=../naviserver-pg/$(STAMP_BUILD)
openacs/$(STAMP_BUILDX_MAN): naviserver-pg/$(STAMP_BUILDX_MAN) sync
$(MAKE) -C openacs buildx BASE_STAMP=../naviserver-pg/$(STAMP_BUILDX_MAN)
# ---- loop helpers ----
define run_core
@set -e; \
for c in $(CORE_COMPONENTS); do \
printf '==> %b%s%b: $(1) (BASE=$(BASE))\n' "$(BOLD)" "$$c" "$(RESET)"; \
$(MAKE) -C $$c $(1); \
done
endef
define run_alpine_only
@set -e; \
for c in $(ALPINE_ONLY_COMPONENTS); do \
printf '==> %b%s%b: $(1) (BASE=alpine)\n' "$(BOLD)" "$$c" "$(RESET)"; \
$(MAKE) -C $$c $(1) BASE=alpine; \
done
endef
# ---- main targets ----
#build: naviserver/$(STAMP_BUILD) naviserver-pg/$(STAMP_BUILD) naviserver-oracle/$(STAMP_BUILD) openacs/$(STAMP_BUILD)
build: naviserver/$(STAMP_BUILD) naviserver-pg/$(STAMP_BUILD) openacs/$(STAMP_BUILD)
$(call run_alpine_only,build)
#buildx: naviserver/$(STAMP_BUILDX_MAN) naviserver-pg/$(STAMP_BUILDX_MAN) naviserver-oracle/$(STAMP_BUILDX_MAN) openacs/$(STAMP_BUILDX_MAN)
buildx: naviserver/$(STAMP_BUILDX_MAN) naviserver-pg/$(STAMP_BUILDX_MAN) openacs/$(STAMP_BUILDX_MAN)
$(call run_alpine_only,buildx)
# ---- per-component convenience ----
build-%: sync
@if echo "$(ALPINE_ONLY_COMPONENTS)" | tr ' ' '\n' | grep -qx "$*"; then \
BASE=alpine; \
else \
BASE="$(BASE)"; \
fi; \
printf '==> %b%s%b: build (BASE=%s)\n' "$(BOLD)" "$*" "$(RESET)" "$$BASE"; \
$(MAKE) -C $* build BASE="$$BASE"
buildx-%: sync
@if echo "$(ALPINE_ONLY_COMPONENTS)" | tr ' ' '\n' | grep -qx "$*"; then \
BASE=alpine; \
else \
BASE="$(BASE)"; \
fi; \
printf '==> %b%s%b: buildx (BASE=%s)\n' "$(BOLD)" "$*" "$(RESET)" "$$BASE"; \
$(MAKE) -C $* buildx BASE="$$BASE"
clean:
@set -e; \
for c in $(CORE_COMPONENTS) $(ALPINE_ONLY_COMPONENTS); do \
echo "==> $$c: clean"; \
$(MAKE) -C $$c clean; \
done
rebuild: clean build
rebuildx: clean buildx
help:
@printf "%s\n" "docker-ns Makefile targets"
@printf "%s\n" "========================="
@printf "\n%s\n" "Common:"
@printf " %-28s %s\n" "make" "Build all images locally (no push)"
@printf " %-28s %s\n" "make help" "Show this help"
@printf "\n%s\n" "Local builds (recommended when you changed files in this repo):"
@printf " %-28s %s\n" "make build-naviserver" "Build NaviServer image locally"
@printf " %-28s %s\n" "make build-openacs" "Build OpenACS image locally"
@printf " %-28s %s\n" "make build-mail-relay" "Build mail-relay image locally"
@printf " %-28s %s\n" "make build-munin-node" "Build munin-node image locally"
@printf " %-28s %s\n" "make build-munin-master" "Build munin-master image locally"
@printf "\n%s\n" "Using -local tags:"
@printf " %-28s %s\n" "make LOCAL_TAG=-local build-openacs" "Build as ...:latest-local (no push)"
@printf " %-28s %s\n" "make LOCAL_TAG=-local" "Build all as ...:latest-local (no push)"
@printf "\n%s\n" "Multi-arch builds (buildx) – builds AND pushes to Docker Hub:"
@printf " %-28s %s\n" "make buildx-openacs" "Multi-arch build + push OpenACS image"
@printf " %-28s %s\n" "make buildx-TARGET" "Same tags as with: make build-TARGET"
@printf " %-28s %s\n" "make buildx NOCACHE_AMD64=1 NOCACHE_ARM64=1" "Multi-arch Build with no cache"
@printf "\n%s\n" "Versioned builds (examples):"
@printf " %-28s %s\n" "make VERSION_NS=5.0.3 RELEASE_TAG=5.0.3 build" "Local versioned build"
@printf " %-28s %s\n" "make VERSION_NS=5.0.3 RELEASE_TAG=5.0.3 buildx-openacs" "Multi-arch versioned build + push"
@printf "\n%s\n" "Variables:"
@printf " %-28s %s\n" "LOCAL_TAG=-local" "Append suffix to image tags (e.g. :latest-local)"
@printf " %-28s %s\n" "RELEASE_TAG=<tag>" "Image tag to build (e.g. 5.0.3, latest)"
@printf " %-28s %s\n" "VERSION_NS=<ver>" "NaviServer version (used by some images/builds)"
@printf "\n%s\n" "Notes:"
@printf " %s\n" "- buildx targets require docker login + push rights to the Docker Hub repo."
@printf " %s\n" "- If you modified files locally, prefer LOCAL_TAG=-local and reference that tag"
@printf " %s\n" " (e.g. gustafn/openacs:latest-local) in docker-compose."
.PHONY: help rebuild