forked from wso2/api-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
215 lines (177 loc) · 9.85 KB
/
Makefile
File metadata and controls
215 lines (177 loc) · 9.85 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# --------------------------------------------------------------------
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# --------------------------------------------------------------------
# Gateway Makefile - Coordinate all gateway components
SHELL := /bin/bash
# Read shared version from VERSION file
VERSION := $(shell cat VERSION 2>/dev/null || echo "0.0.1-SNAPSHOT")
# Docker registry configuration
DOCKER_REGISTRY ?= ghcr.io/wso2/api-platform
# Image names
CONTROLLER_IMAGE := $(DOCKER_REGISTRY)/gateway-controller
GATEWAY_BUILDER_IMAGE := $(DOCKER_REGISTRY)/gateway-builder
GATEWAY_RUNTIME_IMAGE := $(DOCKER_REGISTRY)/gateway-runtime
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help message
@echo 'Gateway Build System (Version: $(VERSION))'
@echo ''
@echo 'Build Targets:'
@echo ' make build - Build all gateway component Docker images (buildx)'
@echo ' make build-controller - Build gateway-controller Docker image'
@echo ' make build-controller-debug - Build debug gateway-controller image for remote debugging (dlv on port 2345)'
@echo ' make build-gateway-builder - Build gateway-builder Docker image'
@echo ' make build-gateway-runtime - Build gateway-runtime Docker image (Router + Policy Engine)'
@echo ' make build-debug - Build all debug images (controller + runtime) for remote debugging'
@echo ' make build-gateway-runtime-debug - Build debug gateway-runtime image for remote debugging (dlv on port 2346)'
@echo ''
@echo 'Multi-arch Build and Push Targets:'
@echo ' make build-and-push-multiarch - Build and push all gateway components for multiple architectures'
@echo ' make build-and-push-multiarch-controller - Build and push controller for multiple architectures'
@echo ' make build-and-push-multiarch-gateway-builder - Build and push gateway-builder for multiple architectures'
@echo ' make build-and-push-multiarch-gateway-runtime - Build and push gateway-runtime for multiple architectures'
@echo ''
@echo 'Test Targets:'
@echo ' make test - Run all tests'
@echo ' make test-controller - Test gateway-controller'
@echo ' make test-gateway-builder - Test gateway-builder'
@echo ' make test-policy-engine - Test policy-engine'
@echo ''
@echo 'Integration Test Targets:'
@echo ' make test-integration-all - Build coverage images and run integration tests'
@echo ' make build-coverage - Build all coverage-instrumented gateway components'
@echo ' make build-controller-coverage - Build coverage-instrumented gateway-controller Docker image'
@echo ' make build-gateway-runtime-coverage - Build coverage-instrumented gateway-runtime Docker image'
@echo ' make test-integration - Run integration tests'
@echo ''
@echo 'Version Management:'
@echo ' make version-set VERSION=X - Set gateway version and update artifacts'
@echo ' make version-bump-patch - Bump patch version'
@echo ' make version-bump-minor - Bump minor version'
@echo ' make version-bump-major - Bump major version'
@echo ' make version-bump-next-dev - Bump to next minor dev version with SNAPSHOT'
@echo ' make version-get-release - Get release version (strips SNAPSHOT suffix)'
@echo ''
@echo 'Clean Targets:'
@echo ' make clean - Clean all build artifacts'
# Build Targets
.PHONY: build
build: build-controller build-gateway-builder build-gateway-runtime ## Build all gateway components
.PHONY: build-debug
build-debug: build-controller-debug build-gateway-runtime-debug ## Build all debug images (controller + runtime) for remote debugging
.PHONY: build-coverage
build-coverage: build-gateway-builder build-controller-coverage build-gateway-runtime-coverage ## Build all coverage-instrumented gateway components
.PHONY: build-controller
build-controller: ## Build gateway-controller Docker image
@echo "Building controller Docker image ($(VERSION))..."
$(MAKE) -C gateway-controller build VERSION=$(VERSION)
.PHONY: build-controller-coverage
build-controller-coverage: ## Build coverage-instrumented gateway-controller Docker image
@echo "Building coverage-instrumented controller Docker image ($(VERSION))..."
$(MAKE) -C gateway-controller build-coverage-image VERSION=$(VERSION)
.PHONY: build-controller-debug
build-controller-debug: ## Build debug gateway-controller image for remote debugging
@echo "Building debug controller Docker image ($(VERSION))..."
$(MAKE) -C gateway-controller build-debug VERSION=$(VERSION)
.PHONY: build-gateway-builder
build-gateway-builder: ## Build gateway-builder Docker image
@echo "Building gateway-builder Docker image ($(VERSION))..."
$(MAKE) -C gateway-builder build VERSION=$(VERSION)
.PHONY: build-gateway-runtime
build-gateway-runtime: ## Build gateway-runtime Docker image (Router + Policy Engine)
@echo "Building gateway-runtime Docker image ($(VERSION))..."
$(MAKE) -C gateway-runtime build VERSION=$(VERSION)
.PHONY: build-gateway-runtime-coverage
build-gateway-runtime-coverage: ## Build coverage-instrumented gateway-runtime Docker image
@echo "Building coverage-instrumented gateway-runtime Docker image ($(VERSION))..."
$(MAKE) -C gateway-runtime build-coverage-image VERSION=$(VERSION)
.PHONY: build-gateway-runtime-debug
build-gateway-runtime-debug: ## Build debug gateway-runtime image for remote debugging
@echo "Building debug gateway-runtime Docker image ($(VERSION))..."
$(MAKE) -C gateway-runtime build-debug VERSION=$(VERSION)
# Multi-arch Build and Push Targets
.PHONY: build-and-push-multiarch
build-and-push-multiarch: build-and-push-multiarch-controller build-and-push-multiarch-gateway-builder build-and-push-multiarch-gateway-runtime ## Build and push all gateway components for multiple architectures
.PHONY: build-and-push-multiarch-controller
build-and-push-multiarch-controller: ## Build and push gateway-controller Docker image for multiple architectures
@echo "Building and pushing multi-arch controller Docker image ($(VERSION))..."
$(MAKE) -C gateway-controller build-and-push-multiarch VERSION=$(VERSION)
.PHONY: build-and-push-multiarch-gateway-builder
build-and-push-multiarch-gateway-builder: ## Build and push gateway-builder Docker image for multiple architectures
@echo "Building and pushing multi-arch gateway-builder Docker image ($(VERSION))..."
$(MAKE) -C gateway-builder build-and-push-multiarch VERSION=$(VERSION)
.PHONY: build-and-push-multiarch-gateway-runtime
build-and-push-multiarch-gateway-runtime: ## Build and push gateway-runtime Docker image for multiple architectures
@echo "Building and pushing multi-arch gateway-runtime Docker image ($(VERSION))..."
$(MAKE) -C gateway-runtime build-and-push-multiarch VERSION=$(VERSION)
# Test Targets
.PHONY: test
test: test-controller test-gateway-builder test-policy-engine ## Run all tests
.PHONY: test-controller
test-controller: ## Test gateway-controller
$(MAKE) -C gateway-controller test
.PHONY: test-gateway-builder
test-gateway-builder: ## Test gateway-builder
$(MAKE) -C gateway-builder test
.PHONY: test-policy-engine
test-policy-engine: ## Test policy-engine
$(MAKE) -C gateway-runtime test
.PHONY: test-integration
test-integration: ## Run integration tests
$(MAKE) -C it test
.PHONY: test-integration-all
test-integration-all: build-coverage test-integration ## Build coverage images and run integration tests
# Version Management Targets
.PHONY: version-set
version-set: ## Set gateway version and update artifacts
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION required"; \
echo "Usage: make version-set VERSION=1.0.0"; \
exit 1; \
fi
@echo "$(VERSION)" > VERSION
@sed -i.bak 's/^ version: .*/ version: $(VERSION)/' build.yaml && rm -f build.yaml.bak
@sed -i.bak 's/^ version: .*/ version: $(VERSION)/' sample-policies/build.yaml && rm -f sample-policies/build.yaml.bak
@(cd .. && bash scripts/update-docker-compose.sh gateway $(VERSION))
@(cd .. && bash scripts/update-helm.sh gateway $(VERSION))
@echo "✓ Set gateway version to $(VERSION)"
.PHONY: version-bump-patch
version-bump-patch: ## Bump patch version
@$(MAKE) version-set VERSION=$$(cd .. && bash scripts/next-version.sh patch gateway)
.PHONY: version-bump-minor
version-bump-minor: ## Bump minor version
@$(MAKE) version-set VERSION=$$(cd .. && bash scripts/next-version.sh minor gateway)
.PHONY: version-bump-major
version-bump-major: ## Bump major version
@$(MAKE) version-set VERSION=$$(cd .. && bash scripts/next-version.sh major gateway)
.PHONY: version-bump-next-dev
version-bump-next-dev: ## Bump to next minor dev version with SNAPSHOT suffix
@$(MAKE) version-set VERSION=$$(cd .. && bash scripts/next-version.sh next-dev gateway)
.PHONY: version-get-release
version-get-release: ## Get release version (strips SNAPSHOT suffix)
@VERSION=$$(cat VERSION 2>/dev/null | tr -d '[:space:]' | sed 's/-SNAPSHOT//'); \
if [ -z "$$VERSION" ]; then \
echo "Error: VERSION is empty or contains only whitespace. Check gateway/VERSION file." >&2; \
exit 1; \
fi; \
echo "$$VERSION"
# Clean Targets
.PHONY: clean
clean: ## Clean all build artifacts
$(MAKE) -C gateway-controller clean
$(MAKE) -C gateway-builder clean
$(MAKE) -C gateway-runtime clean